From: "H. Peter Anvin" <hpa@zytor.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
LKML <linux-kernel@vger.kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Kees Cook <keescook@chromium.org>, Will Drewry <wad@chromium.org>
Subject: Re: pt_regs->ax == -ENOSYS
Date: Tue, 27 Apr 2021 17:46:42 -0700 [thread overview]
Message-ID: <87bda691-9201-06cd-9850-c92a05a399c7@zytor.com> (raw)
In-Reply-To: <3a502aae-4124-5cb2-1dac-bc18b8158fbe@zytor.com>
On 4/27/21 5:20 PM, H. Peter Anvin wrote:
>
> We *used* to truncate the system call number; that was unsigned. It
> causes massive headache to ptrace if a 32-bit ptrace wants to write -1,
> which is a bit hacky.
>
> I would personally like to see orig_ax to be the register passed in and
> for the truncation to happen by syscall_get_nr().
>
> I also note that kernel/seccomp.c and the tracing infrastructure all
> expect a signed int as the system call number. Yes, orig_ax is a 64-bit
> field, but so are the other register fields which doesn't necessarily
> directly reflect the value of an argument -- like, say, %rdi in the case
> of sys_write - it is an int argument so it gets sign extended; this is
> *not* reflected in ptrace.
>
> -hpa
We could even do this, to make it perhaps harder to mess up:
diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index 409f661481e1..4e8e5c2e35f4 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -41,7 +41,10 @@ struct pt_regs {
unsigned short gs;
unsigned short __gsh;
/* On interrupt, this is the error code. */
- unsigned long orig_ax;
+ union {
+ unsigned long orig_ax;
+ int syscall_nr;
+ };
unsigned long ip;
unsigned short cs;
unsigned short __csh;
@@ -78,7 +81,10 @@ struct pt_regs {
* On syscall entry, this is syscall#. On CPU exception, this is error
code.
* On hw interrupt, it's IRQ number:
*/
- unsigned long orig_ax;
+ union {
+ unsigned long orig_ax;
+ int syscall_nr;
+ };
/* Return frame for iretq */
unsigned long ip;
unsigned long cs;
next prev parent reply other threads:[~2021-04-28 0:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 21:15 H. Peter Anvin
2021-04-27 21:28 ` Andy Lutomirski
2021-04-27 22:58 ` H. Peter Anvin
2021-04-27 23:23 ` Andy Lutomirski
2021-04-28 0:05 ` H. Peter Anvin
2021-04-28 0:11 ` Andy Lutomirski
2021-04-28 0:20 ` H. Peter Anvin
2021-04-28 0:46 ` H. Peter Anvin [this message]
2021-04-27 23:29 ` Kees Cook
2021-04-27 23:51 ` Andy Lutomirski
2021-04-28 2:05 ` Kees Cook
2021-04-28 2:07 ` H. Peter Anvin
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=87bda691-9201-06cd-9850-c92a05a399c7@zytor.com \
--to=hpa@zytor.com \
--cc=bp@alien8.de \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=wad@chromium.org \
/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
all inboxes | Powered by JetHome®