From: Linus Torvalds <torvalds@linuxfoundation.org>
To: 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>, "H . Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 1/3] x86: Move TSS and LDT to end of the GDT
Date: Wed, 13 Dec 2023 10:51:11 -0800 [thread overview]
Message-ID: <CAHk-=whgooqaEBK27sBMHob9+PwqaZghEsGnSVJsHK=y8U05tw@mail.gmail.com> (raw)
In-Reply-To: <20231213163443.70490-2-brgerst@gmail.com>
On Wed, 13 Dec 2023 at 08:34, Brian Gerst <brgerst@gmail.com> wrote:
>
> This will make testing for system segments easier.
It seems to make more sense organizationally too, with the special
non-data/code segments clearly separate at the end.
So I think this is fine conceptually.
HOWEVER, I think that you might want to expand on this a bit more,
because there are other special segments selectors that might not be
thing you want to expose to user space.
We have GDT_ENTRY_PERCPU for example, which is a kernel-only segment.
It also happens to be 32-bit only, it doesn't matter for the thing
you're trying to fix, but that valid_user_selector() thing is then
used on x86-32 too.
So the ESPFIX and per-cpu segments are kernel-only, but then the VDSO
getcpu one is a user segment.
And the PnP and APM BIOS segments are similarly kernel-only.
But then the VDSO getcpu segment is user-visible, in the middle, and
again, it's 32-bit only but that whole GDT_SYSTEM_START thing is
supposed to work there too.
End result: this seems incomplete and not really fully baked.
I wonder if instead of GDT_SYSTEM_START, you'd be better off just
making a trivial constant bitmap of "these are user visible segments
in the GDT". No need to re-order things, just have something like
#define USER_SEGMENTS_MASK \
((1ul << GDT_ENTRY_DEFAULT_USER_CS) |
,,,,
and use that for the test (remember to check for GDT_ENTRIES as the max).
Hmm?
Linus
next prev parent reply other threads:[~2023-12-13 18:51 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 [this message]
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
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='CAHk-=whgooqaEBK27sBMHob9+PwqaZghEsGnSVJsHK=y8U05tw@mail.gmail.com' \
--to=torvalds@linuxfoundation.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).