Re: [PATCH 06/18] x86, barrier: stop speculation for failed access_ok

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
2018-01-06 17:56:15
Also in
lkml, netdev
Reply to
Alan Cox, 2018-01-06
On Sat, Jan 6, 2018 at 4:32 AM, Alan Cox [off-list ref] wrote:
Also for x86-64 if we are trusting that an AND with a constant won't get
speculated into something else surely we can just and the address with ~(1
<< 63) before copying from/to user space ? The user will then just
speculatively steal their own memory.
User accesses *may* go to the kernel too, with set_fs(KERNEL_DS).
We've been getting rid of those, but they still exist.

We historically perhaps have 'and'ed the address with
current->thread.addr_limit, but it's no longer a power-of-two mask, so
that doesn't work. We'd have to play tricks there, but it might work
to do something like

     addr &= current->thread.addr_limit | 0xfff;

or similar.

But this is one area where the 'lfence' is probably not too bad. The
cost of the existing 'stac' instruction is much higher, and in fact
depending on how lfence works (and how stac affects the memory unit
pipeline, it might even _help_ to serialize the stac with the actual
address.

            Linus
Thread (136 messages) 136 messages, 29 authors, last reply 2018-01-12
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help