• Linus Torvalds's avatar
    Convert filldir[64]() from __put_user() to unsafe_put_user() · 9f79b78e
    Linus Torvalds authored
    We really should avoid the "__{get,put}_user()" functions entirely,
    because they can easily be mis-used and the original intent of being
    used for simple direct user accesses no longer holds in a post-SMAP/PAN
    world.
    
    Manually optimizing away the user access range check makes no sense any
    more, when the range check is generally much cheaper than the "enable
    user accesses" code that the __{get,put}_user() functions still need.
    
    So instead of __put_user(), use the unsafe_put_user() interface with
    user_access_{begin,end}() that really does generate better code these
    days, and which is generally a nicer interface.  Under some loads, the
    multiple user writes that filldir() does are actually quite noticeable.
    
    This also makes the dirent name copy use unsafe_put_user() with a couple
    of macros.  We do not want to make function calls with SMAP/PAN
    disabled, and the code this generates is quite good when the
    architecture uses "asm goto" for unsafe_put_user() like x86 does.
    
    Note that this doesn't bother with the legacy cases.  Nobody should use
    them anyway, so performance doesn't really matter there.
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    9f79b78e
readdir.c 13.5 KB