• Linus Torvalds's avatar
    x86-64: mm: clarify the 'positive addresses' user address rules · 798dec33
    Linus Torvalds authored
    Dave Hansen found the "(long) addr >= 0" code in the x86-64 access_ok
    checks somewhat confusing, and suggested using a helper to clarify what
    the code is doing.
    
    So this does exactly that: clarifying what the sign bit check is all
    about, by adding a helper macro that makes it clear what it is testing.
    
    This also adds some explicit comments talking about how even with LAM
    enabled, any addresses with the sign bit will still GP-fault in the
    non-canonical region just above the sign bit.
    
    This is all what allows us to do the user address checks with just the
    sign bit, and furthermore be a bit cavalier about accesses that might be
    done with an additional offset even past that point.
    
    (And yes, this talks about 'positive' even though zero is also a valid
    user address and so technically we should call them 'non-negative'.  But
    I don't think using 'non-negative' ends up being more understandable).
    Suggested-by: default avatarDave Hansen <dave.hansen@intel.com>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    798dec33
uaccess_64.h 5.27 KB