Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1605312

Re: [PATCH tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS segments

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [PATCH tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS segments
Date 2017-03-21 06:20 +0100
Message-ID <tnkn7-7aS-1@gated-at.bofh.it> (permalink)
References <tmBzI-XZ-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Mar 18, 2017 at 10:17 PM, Andy Lutomirski <luto@kernel.org> wrote:
> For mysterious historical reasons, struct user_desc doesn't indicate
> whether segments are accessed.  set_thread_area() has always
> programmed segments as non-accessed, so the first write will set the
> accessed bit.  This will fault if the GDT is read-only.
>
> Fix it by making TLS segments start out accessed.
>
> If this ends up breaking something, we could, in principle, leave
> TLS segments non-accessed and fix them up when we get the page
> fault.  I'd be surprised, though -- AFAIK all the nasty legacy
> segmented programs (DOSEMU, Wine, things that run on DOSEMU and
> Wine, etc.) do their nasty segmented things using the LDT and not
> the GDT.  I assume this is mainly because old OSes (Linux and
> otherwise) didn't historically provide APIs to do nasty things in
> the GDT.
>
> Fixes: 45fc8757d1d2 ("x86: Make the GDT remapping read-only on 64-bit")
> Signed-off-by: Andy Lutomirski <luto@kernel.org>

FWIW, I'm now extra convinced that this won't break anything: the
accessed bit didn't work properly before this patch.  When we
scheduled a task in, we'd copy the TLS segment descriptors to the GDT,
but we never copied them back out when we scheduled out, so the
accessed bit would randomly clear itself.  Whoops :)

So arguably this patch would be a bugfix even without Thomas' changes.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS segments Andy Lutomirski <luto@kernel.org> - 2017-03-19 06:30 +0100
  [tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS segments tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2017-03-19 12:30 +0100
  Re: [PATCH tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS segments Andy Lutomirski <luto@amacapital.net> - 2017-03-21 06:20 +0100
    Re: [PATCH tip:x86/mm] x86/tls: Forcibly set the accessed bit in TLS  segments Ingo Molnar <mingo@kernel.org> - 2017-03-21 08:30 +0100

csiph-web