Message ID | 1467105996-18063-1-git-send-email-yao.qi@linaro.org |
---|---|
State | New, archived |
Headers |
Received: (qmail 59783 invoked by alias); 28 Jun 2016 09:26:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 59772 invoked by uid 89); 28 Jun 2016 09:26:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=123456789, sends, 2016-06-28 X-HELO: mail-pa0-f67.google.com Received: from mail-pa0-f67.google.com (HELO mail-pa0-f67.google.com) (209.85.220.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 28 Jun 2016 09:26:43 +0000 Received: by mail-pa0-f67.google.com with SMTP id ts6so1231308pac.0 for <gdb-patches@sourceware.org>; Tue, 28 Jun 2016 02:26:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=CRYcxDLSxACWZqrSv2msOIPAC0T62t1ehxaU7UI6LTc=; b=OfwGg5iAteEg1z99xzXlwB3B1sVbB8SKFcazYDyfVA0MIs+6Di22BJ93oOGbwdgaA3 5O7adolApU8IjWRkXSBiziBEBgEg+CRZiLeIe4tKP+Rv0zvkdaUhXycdlegsowe0dEIi 1k8tfJgUnf2sm8wsKYq53U3CqiQyTtSeFLG7TivD6AQ1hOHKOIwfluZIkh8LkaYhENlw cMLMyZsdrOXm+WlT1bfLLCDcZoCAdjCsWVV7zYIZhJ223pnZvm8BGhh/0v3/RSXVcRYU +60U+UgXQ5FmCxC4GWdVCs6CCXkNc2j8iblp9HsAHs65qSXL0WkA4hpCNoQkE7fUPprE XYVQ== X-Gm-Message-State: ALyK8tKzwG6dis8XU4zBAJWK4bXg3cR8iUqbEnHYYgyEvQ0WbJNcJtyT1edMutDG8SCjYw== X-Received: by 10.66.185.229 with SMTP id ff5mr132406pac.132.1467106001482; Tue, 28 Jun 2016 02:26:41 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id m8sm5711250pfi.27.2016.06.28.02.26.40 for <gdb-patches@sourceware.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Jun 2016 02:26:40 -0700 (PDT) From: Yao Qi <qiyaoltc@gmail.com> X-Google-Original-From: Yao Qi <yao.qi@linaro.org> To: gdb-patches@sourceware.org Subject: [PATCH] Set unknown_syscall differently on arm linux Date: Tue, 28 Jun 2016 10:26:36 +0100 Message-Id: <1467105996-18063-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes |
Commit Message
Yao Qi
June 28, 2016, 9:26 a.m. UTC
Currently, we use 123456789 as unknown or illegal syscall number, and expect program return ENOSYS. Although 123456789 is an illegal syscall number on arm linux, kernel sends SIGILL rather than returns -ENOSYS. However, arm linux kernel returns -ENOSYS if syscall number is within 0xf0001..0xf07ff, so we can use 0xf07ff for unknown_syscall in test. gdb/testsuite: 2016-06-28 Yao Qi <yao.qi@linaro.org> * gdb.base/catch-syscall.c [__arm__]: Set unknown_syscall to 0x0f07ff. --- gdb/testsuite/gdb.base/catch-syscall.c | 4 ++++ 1 file changed, 4 insertions(+)
Comments
On 06/28/2016 10:26 AM, Yao Qi wrote: > Currently, we use 123456789 as unknown or illegal syscall number, and > expect program return ENOSYS. Although 123456789 is an illegal syscall > number on arm linux, kernel sends SIGILL rather than returns -ENOSYS. > However, arm linux kernel returns -ENOSYS if syscall number is within > 0xf0001..0xf07ff, so we can use 0xf07ff for unknown_syscall in test. > I think it'd be good if this was converted to a comment in the source. > --- a/gdb/testsuite/gdb.base/catch-syscall.c > +++ b/gdb/testsuite/gdb.base/catch-syscall.c > @@ -28,7 +28,11 @@ int pipe_syscall = SYS_pipe; > int pipe2_syscall = SYS_pipe2; > #endif > int write_syscall = SYS_write; > +#if defined(__arm__) > +int unknown_syscall = 0x0f07ff; > +#else > int unknown_syscall = 123456789; > +#endif > int exit_group_syscall = SYS_exit_group; > Thanks, Pedro Alves
On Wed, Jun 29, 2016 at 10:53 AM, Pedro Alves <palves@redhat.com> wrote: > On 06/28/2016 10:26 AM, Yao Qi wrote: >> Currently, we use 123456789 as unknown or illegal syscall number, and >> expect program return ENOSYS. Although 123456789 is an illegal syscall >> number on arm linux, kernel sends SIGILL rather than returns -ENOSYS. >> However, arm linux kernel returns -ENOSYS if syscall number is within >> 0xf0001..0xf07ff, so we can use 0xf07ff for unknown_syscall in test. >> > > I think it'd be good if this was converted to a comment in the source. > OK, I move them into the comments as below, +#if defined(__arm__) +/* Although 123456789 is an illegal syscall umber on arm linux, kernel + sends SIGILL rather than returns -ENOSYS. However, arm linux kernel + returns -ENOSYS if syscall number is within 0xf0001..0xf07ff, so we + can use 0xf07ff for unknown_syscall in test. */ +int unknown_syscall = 0x0f07ff; +#else int unknown_syscall = 123456789; +#endif patch is pushed in.
On 28 Jun 2016 10:26, Yao Qi wrote: > Currently, we use 123456789 as unknown or illegal syscall number, and > expect program return ENOSYS. Although 123456789 is an illegal syscall > number on arm linux, kernel sends SIGILL rather than returns -ENOSYS. err, what ? calling random syscalls should not result in signals being generated (ignoring obvious ones like __NR_kill). is the kernel broken ? i think this needs more investigation & explanation. -mike
On Wed, Jun 29, 2016 at 6:41 PM, Mike Frysinger <vapier@gentoo.org> wrote: > On 28 Jun 2016 10:26, Yao Qi wrote: >> Currently, we use 123456789 as unknown or illegal syscall number, and >> expect program return ENOSYS. Although 123456789 is an illegal syscall >> number on arm linux, kernel sends SIGILL rather than returns -ENOSYS. > > err, what ? calling random syscalls should not result in signals being > generated (ignoring obvious ones like __NR_kill). is the kernel broken ? > i think this needs more investigation & explanation. I checked kernel source arch/arm/kernel/traps.c:arm_syscall, and that is how I get the knowledge that kernel doesn't raise SIGIILL if sysno is within 0xf0001..0xf07ff. That is intentional, but I don't know why arm kernel behaves this way.
On 30 Jun 2016 08:52, Yao Qi wrote: > On Wed, Jun 29, 2016 at 6:41 PM, Mike Frysinger <vapier@gentoo.org> wrote: > > On 28 Jun 2016 10:26, Yao Qi wrote: > >> Currently, we use 123456789 as unknown or illegal syscall number, and > >> expect program return ENOSYS. Although 123456789 is an illegal syscall > >> number on arm linux, kernel sends SIGILL rather than returns -ENOSYS. > > > > err, what ? calling random syscalls should not result in signals being > > generated (ignoring obvious ones like __NR_kill). is the kernel broken ? > > i think this needs more investigation & explanation. > > I checked kernel source arch/arm/kernel/traps.c:arm_syscall, and that is how > I get the knowledge that kernel doesn't raise SIGIILL if sysno is within > 0xf0001..0xf07ff. That is intentional, but I don't know why arm kernel behaves > this way. wow, that code is messed up. can you raise a bug with them ? there's even more code paths in there that result in SIGSEGV too. the history predates 2.4.0 afaict. -mike
On Thu, Jun 30, 2016 at 1:58 PM, Mike Frysinger <vapier@gentoo.org> wrote: > > wow, that code is messed up. can you raise a bug with them ? there's > even more code paths in there that result in SIGSEGV too. the history > predates 2.4.0 afaict. Sure, I can raise a bug somewhere or ask it in arm kernel mail list, but why do you think it is a bug that SIGILL is raised when an illegal/unknown syscall number is passed to syscall? because other archs don't behave this way?
On 30 Jun 2016 15:48, Yao Qi wrote: > On Thu, Jun 30, 2016 at 1:58 PM, Mike Frysinger <vapier@gentoo.org> wrote: > > wow, that code is messed up. can you raise a bug with them ? there's > > even more code paths in there that result in SIGSEGV too. the history > > predates 2.4.0 afaict. > > Sure, I can raise a bug somewhere or ask it in arm kernel mail list, but > why do you think it is a bug that SIGILL is raised when an illegal/unknown > syscall number is passed to syscall? because other archs don't behave > this way? correct -- i know of no other arch that behaves this way. the syscall ABI is supposed to communicate errors via return values (which are errno values), not by sending signals which kill the process. -mike
diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c index 98222fa..2e3c5d1 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.c +++ b/gdb/testsuite/gdb.base/catch-syscall.c @@ -28,7 +28,11 @@ int pipe_syscall = SYS_pipe; int pipe2_syscall = SYS_pipe2; #endif int write_syscall = SYS_write; +#if defined(__arm__) +int unknown_syscall = 0x0f07ff; +#else int unknown_syscall = 123456789; +#endif int exit_group_syscall = SYS_exit_group; /* Set by the test when it wants execve. */