From: liubo <liubo2009@cn.fujitsu.com>
To: Garrett Cooper <yanegomi@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>, ltp-list <ltp-list@lists.sf.net>
Subject: Re: [LTP] [PATCH] syscalls: fix some failure on arch X86_64
Date: Fri, 27 Nov 2009 13:33:43 +0800 [thread overview]
Message-ID: <4B0F64B7.6060507@cn.fujitsu.com> (raw)
In-Reply-To: <364299f40911260311m6d157453s47f57d1ba47ef643@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 12575 bytes --]
Hi, Garrett
On 11/26/2009 07:11 PM, Garrett Cooper wrote:
> On Mon, Nov 16, 2009 at 12:53 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>
>> Hi, Subrata,
>> On 11/16/2009 04:13 PM, Subrata Modak wrote:
>>
>> Liubo,
>>
>> Are you sending an updated patch post this discussion ?
>>
>>
>>
>> Yes, I'll resend a updated patch about these rt_sigs.
>>
>> Regards--
>> Liubo
>>
>> Regards--
>> Subrata
>>
>> On Wed, 2009-11-11 at 13:03 +0800, Wei Yongjun wrote:
>>
>>
>> Mike Frysinger wrote:
>>
>>
>> On Tuesday 10 November 2009 04:38:30 liubo wrote:
>>
>>
>>
>> 1) rt_sigaction
>> "sigaction" has the structure:
>>
>> struct sigaction {
>> __sighandler_t sa_handler;
>> unsigned long sa_flags;
>> #ifdef SA_RESTORER
>> __sigrestore_t sa_restorer;
>> #endif
>> sigset_t sa_mask; /* mask last for extensibility */
>> };
>>
>> However, on arch x86_64, if we directly get to call rt_sigaction,
>> the argument "sa_restorer" will not be fulfilled, and this will lead
>> to segment fault.
>> on arch x86_64, if sa_restorer is not set, kernel will lead to segment
>> fault. In other arch, if sa_restorer is not set, kernel can do the correct
>> work. To avoid this segment fault, we use glibc function
>> "int sigaction(...);" instead, which can fulfill the argument
>> "sa_restorer".
>>
>>
>>
>> which defeats the purpose of the test. there is no guarantee that the C
>> library sigaction function is implemented via the __NR_rt_sigaction syscall.
>>
>>
>>
>> In x86_64, it do this. And If we want to use __NR_rt_sigaction syscall
>> directly, we must fill the sa_restorer and set the RESTORER flag to
>> sa_mask. If we do not set the sa_restorer, kill will always cause
>> segment fault.
>>
>>
>>
>>
>>
>>
>> 2) rt_sigprocmask
>> This failure contains two aspects,
>> the first is the segment fault as described in 1),
>> the second is that testcase uses a unknown signal 33 for test,
>> and this will lead sigaction cannot bind signal 33 to the action.
>>
>> So, we attempt to use a known signal instead, such as 34.
>>
>>
>>
>> which is just as bogus and unportable. if the test needs a real time
>> signal,
>> it should leverage the sigrtmin...sigrtmax defines.
>> -mike
>>
>
> I see what you mean about this testcase segfaulting now.
>
> I've done some exploring, and while sigaction does map to rt_sigaction
> on ia64 and x86_64, it won't on arm, mips, s390*, sh, or x86.
>
> Furthermore, the problem is actually being caused by the fact that
> we're not even calling sigaddset properly!
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) c
> The program is not being run.
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 1 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 2 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 3 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 4 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 5 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 6 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 7 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 8 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 9 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 10 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 11 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 12 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 13 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 14 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 15 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 16 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 17 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 18 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 19 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 20 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 21 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 22 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 23 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 24 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 25 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 26 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 27 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 28 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 29 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
> rt_sigaction01 0 TINFO : sigaddset(..) failed
> rt_sigaction01 30 TFAIL : rt_sigaction01 failed:
> TEST_ERRNO=EINVAL(22): Invalid argument
>
> So, the test needs fixing, anyhow. After I fixed it, the test still
> segfaulted >:( --
>
> gcooper@orangebox
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction $ gdb
> ./rt_sigaction01
> GNU gdb 6.8
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law. Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-pc-linux-gnu"...
> (gdb) r
> Starting program:
> /scratch/ltp-dev2/ltp/testcases/kernel/syscalls/rt_sigaction/rt_sigaction01
> thread:20
> [Thread debugging using libthread_db enabled]
> rt_sigaction01 0 TINFO : signal: 34
> rt_sigaction01 0 TINFO : sa.sa_flags = SA_RESETHAND|SA_SIGINFO
> [New Thread 0x7fdd451d66f0 (LWP 31927)]
>
> Program received signal SIG34, Real-time event 34.
> [Switching to Thread 0x7fdd451d66f0 (LWP 31927)]
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
> (gdb) c
> Continuing.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00007fdd448944f7 in kill () from /lib/libc.so.6
>
> So I tried to do some digging. glibc 2.8-20080602 does the following
> for alpha, i386, and sysv:
>
> result = INLINE_SYSCALL (rt_sigaction, 4,
> sig, act ? __ptrvalue (&kact) : NULL,
> oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
>
> The kernel code for rt_sigaction in kernel/signal.c is as follows:
>
> #ifdef __ARCH_WANT_SYS_RT_SIGACTION
> SYSCALL_DEFINE4(rt_sigaction, int, sig,
> const struct sigaction __user *, act,
> struct sigaction __user *, oact,
> size_t, sigsetsize)
> {
> struct k_sigaction new_sa, old_sa;
> int ret = -EINVAL;
>
> /* XXX: Don't preclude handling different sized sigset_t's. */
> if (sigsetsize != sizeof(sigset_t))
> goto out;
>
> if (act) {
> if (copy_from_user(&new_sa.sa, act, sizeof(new_sa.sa)))
> return -EFAULT;
> }
>
> ret = do_sigaction(sig, act ? &new_sa : NULL, oact ? &old_sa : NULL);
>
> if (!ret && oact) {
> if (copy_to_user(oact, &old_sa.sa, sizeof(old_sa.sa)))
> return -EFAULT;
> }
> out:
> return ret;
> }
>
> This just blows my mind because rt_sigaction is just calling
> do_sigaction, which is the same code as sigaction AFAICT, apart from
> the fact that rt_sigaction completely disregards sa_restorer on some
> architectures because it's obsolete, and requires the end-user to
> specify a signal mask set (here's mips' version, which wasn't the same
> as i386's version -- i386 had the old sa_restorer code):
>
> SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
> struct sigaction __user *, oact)
> {
> struct k_sigaction new_ka, old_ka;
> int ret;
> int err = 0;
>
> if (act) {
> old_sigset_t mask;
>
> if (!access_ok(VERIFY_READ, act, sizeof(*act)))
> return -EFAULT;
> err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
> err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
> err |= __get_user(mask, &act->sa_mask.sig[0]);
> if (err)
> return -EFAULT;
>
> siginitset(&new_ka.sa.sa_mask, mask);
> }
>
> ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
>
> if (!ret && oact) {
> if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
> return -EFAULT;
> err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
> err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
> err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
> err |= __put_user(0, &oact->sa_mask.sig[1]);
> err |= __put_user(0, &oact->sa_mask.sig[2]);
> err |= __put_user(0, &oact->sa_mask.sig[3]);
> if (err)
> return -EFAULT;
> }
>
> return ret;
> }
>
> I dunno -- maybe someone else can read the kernel code better than me,
> but it looks like there's zero real value to the rt_sigaction
> testcases, because it can be covered by sigaction...
>
>
We just tell guys who use these testcases on arch x86_64 that
"Syscall rt_sigaction cannot be called directly on arch x86_64.",
can we?
> Thanks,
> -Garrett
>
>
>
[-- Attachment #1.2: Type: text/html, Size: 12958 bytes --]
[-- Attachment #2: Type: text/plain, Size: 354 bytes --]
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2009-11-27 5:33 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-10 9:38 [LTP] [PATCH] syscalls: fix some failure on arch X86_64 liubo
2009-11-11 1:28 ` liubo
2009-11-11 4:14 ` Garrett Cooper
2009-11-11 4:30 ` Wei Yongjun
2009-11-11 5:22 ` liubo
2009-11-11 4:33 ` Mike Frysinger
2009-11-11 5:03 ` Wei Yongjun
2009-11-16 8:13 ` Subrata Modak
2009-11-16 8:53 ` liubo
2009-11-26 11:11 ` Garrett Cooper
2009-11-27 5:33 ` liubo [this message]
2009-11-27 6:49 ` Garrett Cooper
2009-11-27 8:50 ` Garrett Cooper
2009-11-27 10:07 ` liubo
2009-11-27 22:18 ` Garrett Cooper
2009-11-29 1:22 ` Wei Yongjun
2009-12-01 0:00 ` Garrett Cooper
2009-12-09 7:29 ` liubo
-- strict thread matches above, loose matches on Subject: below --
2009-12-09 7:34 liubo
2009-12-09 12:14 ` Subrata Modak
2009-12-18 16:03 ` Subrata Modak
2009-12-22 2:51 ` Garrett Cooper
2009-12-22 13:12 ` liubo
2010-02-22 5:21 liubo
2010-02-22 7:56 ` Garrett Cooper
2010-02-22 9:08 ` liubo
2010-02-22 18:05 ` Garrett Cooper
2010-02-23 0:59 ` liubo
2010-02-25 7:26 ` liubo
2010-02-25 10:00 ` Garrett Cooper
2010-02-26 0:35 ` liubo
2010-02-27 4:12 ` Garrett Cooper
2010-02-22 9:20 liubo
2010-02-22 14:45 ` Rishikesh K Rajak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B0F64B7.6060507@cn.fujitsu.com \
--to=liubo2009@cn.fujitsu.com \
--cc=ltp-list@lists.sf.net \
--cc=vapier@gentoo.org \
--cc=yanegomi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox