From: Thomas Gleixner <tglx@linutronix.de>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>,
Joshua Hudson <joshudson@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: x86-ml <x86@kernel.org>
Subject: Re: System Call trashing registers
Date: Fri, 01 Sep 2023 19:03:46 +0200 [thread overview]
Message-ID: <87fs3x4yh9.ffs@tglx> (raw)
In-Reply-To: <dbce949f-d8b5-fb88-af63-21a82e431aa3@gnuweeb.org>
On Fri, Sep 01 2023 at 23:24, Ammar Faizi wrote:
> On 8/24/23 11:15 PM, Joshua Hudson wrote:
>> 2) syscall is documented to trash rcx and r11.
>>
>> What I don't understand is why this hasn't ever led to a security
>> issue due to leaking values from kernel space (in the trashed
>> registers) back to userspace.
>
> That behavior is architectural. It's the 'syscall' instruction that
> clobbers %rcx and %r11. Not the kernel.
>
> The kernel's syscall entry point even saves %rcx and %r11, but at that
> point they've already been overwritten by the syscall instruction
> itself with the original %rip and %rflags values. So they contain
> userspace values. No internal kernel data is leaked in %rcx and %r11.
Correct.
It does not matter which entry method you use. The kernel always saves
all registers and restores them. syscall, sysenter, int80 behave the
same way. The implicit clobber by the syscall instruction is done in
hardware and the kernel can't do anything about it.
I can't reproduce this either and the code tells me that any attempt to
reproduce is futile.
Thanks,
tglx
next prev parent reply other threads:[~2023-09-01 17:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 16:15 System Call trashing registers Joshua Hudson
2023-08-28 15:06 ` Pavel Machek
2023-08-28 16:41 ` Joshua Hudson
2023-08-28 17:06 ` David Laight
2023-08-28 17:11 ` Joshua Hudson
2023-09-01 16:24 ` Ammar Faizi
2023-09-01 17:03 ` Thomas Gleixner [this message]
2023-09-01 17:38 ` Joshua Hudson
2023-09-01 18:49 ` Thomas Gleixner
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=87fs3x4yh9.ffs@tglx \
--to=tglx@linutronix.de \
--cc=ammarfaizi2@gnuweeb.org \
--cc=joshudson@gmail.com \
--cc=linux-kernel@vger.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