From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linuxfoundation.org>,
Brian Gerst <brgerst@gmail.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <peterz@infradead.org>,
Michal Luczaj <mhal@rbox.co>
Subject: Re: [PATCH 3/3] x86/sigreturn: Reject system segements
Date: Sun, 17 Dec 2023 13:07:06 -0800 [thread overview]
Message-ID: <C7EB5080-639B-41EE-B494-869D5D6F60A7@zytor.com> (raw)
In-Reply-To: <CAHk-=whXt7QZV+HDA8=PN1pTBSNTL0ZJrcqtc4af=FtJpjPQeQ@mail.gmail.com>
On December 13, 2023 10:54:00 AM PST, Linus Torvalds <torvalds@linuxfoundation.org> wrote:
>On Wed, 13 Dec 2023 at 08:34, Brian Gerst <brgerst@gmail.com> wrote:
>>
>> @@ -98,7 +98,11 @@ static bool ia32_restore_sigcontext(struct pt_regs *regs,
>>
>> /* Get CS/SS and force CPL3 */
>> regs->cs = sc.cs | 0x03;
>> + if (!valid_user_selector(regs->cs))
>> + return false;
>> regs->ss = sc.ss | 0x03;
>> + if (!valid_user_selector(regs->ss))
>> + return false;
>
>Side note: the SS/CS checks could be stricter than the usual selector tests.
>
>In particular, normal segments can be Null segments. But CS/SS must not be.
>
>Also, since you're now checking the validity, maybe we shouldn't do
>the "force cpl3" any more, and just make it an error to try to load a
>non-cpl3 segment at sigreturn..
>
>That forcing was literally just because we weren't checking it for sanity...
>
> Linus
Not to mention that changing a null descriptor to 3 is wrong.
next prev parent reply other threads:[~2023-12-17 21:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 16:34 [PATCH 0/3] Reject setting system segments from userspace Brian Gerst
2023-12-13 16:34 ` [PATCH 1/3] x86: Move TSS and LDT to end of the GDT Brian Gerst
2023-12-13 18:51 ` Linus Torvalds
2023-12-13 19:08 ` Linus Torvalds
2023-12-16 18:24 ` Vegard Nossum
2023-12-16 18:40 ` Linus Torvalds
2023-12-17 21:09 ` H. Peter Anvin
2023-12-13 16:34 ` [PATCH 2/3] x86/ptrace: Reject system segements Brian Gerst
2023-12-13 16:34 ` [PATCH 3/3] x86/sigreturn: " Brian Gerst
2023-12-13 18:54 ` Linus Torvalds
2023-12-17 21:07 ` H. Peter Anvin [this message]
2023-12-17 21:40 ` Linus Torvalds
2023-12-17 21:45 ` H. Peter Anvin
2023-12-18 8:31 ` Li, Xin3
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=C7EB5080-639B-41EE-B494-869D5D6F60A7@zytor.com \
--to=hpa@zytor.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhal@rbox.co \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linuxfoundation.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
all inboxes | Powered by JetHome®