• Ian Kent's avatar
    autofs: fix AT_NO_AUTOMOUNT not being honored · 42f46148
    Ian Kent authored
    The fstatat(2) and statx() calls can pass the flag AT_NO_AUTOMOUNT which
    is meant to clear the LOOKUP_AUTOMOUNT flag and prevent triggering of an
    automount by the call.  But this flag is unconditionally cleared for all
    stat family system calls except statx().
    
    stat family system calls have always triggered mount requests for the
    negative dentry case in follow_automount() which is intended but prevents
    the fstatat(2) and statx() AT_NO_AUTOMOUNT case from being handled.
    
    In order to handle the AT_NO_AUTOMOUNT for both system calls the negative
    dentry case in follow_automount() needs to be changed to return ENOENT
    when the LOOKUP_AUTOMOUNT flag is clear (and the other required flags are
    clear).
    
    AFAICT this change doesn't have any noticable side effects and may, in
    some use cases (although I didn't see it in testing) prevent unnecessary
    callbacks to the automount daemon.
    
    It's also possible that a stat family call has been made with a path that
    is in the process of being mounted by some other process.  But stat family
    calls should return the automount state of the path as it is "now" so it
    shouldn't wait for mount completion.
    
    This is the same semantic as the positive dentry case already handled.
    
    Link: http://lkml.kernel.org/r/150216641255.11652.4204561328197919771.stgit@pluto.themaw.net
    Fixes: deccf497 ("Make stat/lstat/fstatat pass AT_NO_AUTOMOUNT to vfs_statx()")
    Signed-off-by: default avatarIan Kent <raven@themaw.net>
    Cc: David Howells <dhowells@redhat.com>
    Cc: Colin Walters <walters@redhat.com>
    Cc: Ondrej Holy <oholy@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    42f46148
namei.c 121 KB