Bug 6762 - Some syscalls functions just wrappers for other syscalls
Summary: Some syscalls functions just wrappers for other syscalls
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: tapsets (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-23 21:19 UTC by William Cohen
Modified: 2015-03-17 18:28 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William Cohen 2008-07-23 21:19:27 UTC
When looking through the results of the nightly tests on Red Hat Enterprise
Linux 5 (2.6.18-92.1.6.el5 kernel) a number of the syscall.stp test failed:

FAIL: 64-bit access
FAIL: 64-bit chmod
FAIL: 64-bit forkwait
FAIL: 64-bit link
FAIL: 32-bit access
FAIL: 32-bit chmod
FAIL: 32-bit forkwait
FAIL: 32-bit link

Looking through the output found output like the following for the access test:

access: access ("foobar1", F_OK) = 
  access: faccessat (AT_FDCWD, "foobar1", F_OK) = 0
0

The sys_access function is just a wrapper for the sys_faccessat function. Thus,
the faccessat output occurs in the middle. This is not what users are expecting.

Look at 2.6.26 kernel also saw similar problems with sys_chmod and sys_creat.
Comment 1 Frank Ch. Eigler 2008-10-20 16:50:58 UTC
One possible fix is to extend the syscalls tapset thusly:

# add someplace
global syscall_inplay
probe process.syscall { syscall_inplay[tid()] = $syscall }
probe process.syscall.return { delete syscall_inplay[tid()] }
probe process.thread.end { delete syscall_inplay[tid()] }

# then for each "nestable" system call handler
probe syscall.faccessat = kernel.function(" ...") {
   if (syscall_inplay[tid()]) next;
}


Alternately, one can instrument just the "nester" and "nestee" probe
pairs with similar logic, without general system-wide utrace syscall
probes.


Alternately, one can kludge the test case to accept and ignore such
nesting.  :-(
Comment 2 Mark Wielaard 2008-10-20 18:53:17 UTC
(In reply to comment #1)
> Alternately, one can kludge the test case to accept and ignore such
> nesting.  :-(

I actually did this a while ago:

commit 5311c037f83f66967f9de4cc66815f93940bb005
Author: Mark Wielaard <mjw@redhat.com>
Date:   Sun Oct 5 00:29:49 2008 +0200

    Expect syscall faccessat, fchmodat, linkat, symlinkat, readlinkat chain-call

diff --git a/testsuite/systemtap.syscall/ChangeLog b/testsuite/systemtap.syscall
index 772f980..7cb97df 100644
--- a/testsuite/systemtap.syscall/ChangeLog
+++ b/testsuite/systemtap.syscall/ChangeLog
@@ -1,3 +1,11 @@
+2008-10-04  Mark Wielaard  <mjw@redhat.com>
+
+       * access.c: sys_access() calls through to sys_faccessat().
+       * chmod.c: sys_chmod() calls through to sys_fchmodat().
+       * link.c: sys_link() calls through to sys_linkat(),
+       sys_symlink() calls through to sys_symlinkat(),
+       sys_readlink() calls through to sys_readlinkat().
Comment 3 David Smith 2010-01-13 21:02:10 UTC
Since these failures no longer occur on current Red Hat Enterprise
Linux 5 (2.6.18-164.el5), I'm closing this one.
Comment 4 Frank Ch. Eigler 2010-02-16 20:04:57 UTC
This problem periodically reoccurs; we will have to deal with it
properly.  See bug #11263.
Comment 5 David Smith 2015-03-17 18:28:33 UTC
(In reply to Frank Ch. Eigler from comment #4)
> This problem periodically reoccurs; we will have to deal with it
> properly.  See bug #11263.

As part of all the syscall tapset work that's been done recently (bug #16716), a fix to avoid syscall nesting has been developed (originally for bug #15219). This fix involves use of the @__syscall_gate() family of macros. This fix basically says if we're in syscall.faccessat, but the syscall number isn't __NR_faccessat, return.

Every known instance of this problem has been fixed. It is likely there are problems with syscalls without a test program. We'll have to tackle these as we continue work in this area.

I'm going mark this bug as resolved, and we'll just file individual bugs on syscalls without test programs and fix nesting problems then.