From: "H. Peter Anvin" <hpa@zytor.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Ben Hutchings <ben@decadent.org.uk>,
Andy Lutomirski <luto@kernel.org>, X86 ML <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/entry/x32: Check top 32 bits of syscall number on the fast path
Date: Sun, 17 Apr 2016 22:21:14 -0700 [thread overview]
Message-ID: <57146ECA.5000901@zytor.com> (raw)
In-Reply-To: <CALCETrUVuaTvYuLy=w6ZR8_1JAvOW=Gz5BT_3=OBK844r6e1Yg@mail.gmail.com>
On 04/17/16 22:18, Andy Lutomirski wrote:
> On Sun, Apr 17, 2016 at 9:50 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>> On 04/17/16 17:47, Ben Hutchings wrote:
>>> We've always masked off the top 32 bits when x32 is enabled, but
>>> hopefully no-one relies on that. Now that the slow path is in C, we
>>> check all the bits there, regardless of whether x32 is enabled. Let's
>>> make the fast path consistent with it.
>>
>> We have always masked off the top 32 bits *period*.
>>
>> We have had some bugs where we haven't, because someone has tried to
>> "optimize" the code and they have been quite serious. The system call
>> number is an int, which means the upper 32 bits are undefined on call
>> entry: we HAVE to mask them.
>
> I'm reasonably confident that normal kernels (non-x32) have not masked
> those bits since before I started hacking on the entry code.
>
I'm reasonably confident they have, because we have had security bugs
TWICE when someone has tried to "optimize" the code. The masking was
generally done with a movl instruction, which confused people.
> So the type of the syscall nr is a bit confused. If there was an
> installed base of programs that leaved garbage in the high bits, we
> would have noticed *years* ago. On the other hand, the 32-bit ptrace
> ABI and the seccomp ABI both think it's 32-bits.
Incorrect. We have seen these failures in real life.
> If we were designing the x86_64 ABI and everything around it from
> scratch, I'd suggest that that either the high bits must be zero or
> that the number actually be 64 bits (which are more or less the same
> thing). That would let us use the high bits for something interesting
> in the future.
Not really all that useful. What we have is a C ABI.
> In practice, we can probably still declare that the thing is a 64-bit
> number, given that most kernels in the wild currently fail syscalls
> that have the high bits set.
They don't, and we can prove it...
-hpa
next prev parent reply other threads:[~2016-04-18 5:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 17:22 System call number masking Ben Hutchings
2016-04-14 17:48 ` Andy Lutomirski
2016-04-18 0:45 ` Ben Hutchings
2016-04-18 0:47 ` [PATCH] x86/entry/x32: Check top 32 bits of syscall number on the fast path Ben Hutchings
2016-04-18 4:50 ` H. Peter Anvin
2016-04-18 5:18 ` Andy Lutomirski
2016-04-18 5:21 ` H. Peter Anvin [this message]
2016-04-18 5:39 ` Andy Lutomirski
2016-04-18 5:45 ` H. Peter Anvin
2016-04-18 5:48 ` Andy Lutomirski
2016-04-18 6:01 ` H. Peter Anvin
2016-04-18 6:14 ` Andy Lutomirski
2016-04-18 6:19 ` H. Peter Anvin
2016-04-18 5:24 ` 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=57146ECA.5000901@zytor.com \
--to=hpa@zytor.com \
--cc=ben@decadent.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=x86@kernel.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