• David Howells's avatar
    afs: Fix directory permissions check · e36bc993
    David Howells authored
    [ Upstream commit 378831e4 ]
    
    Doing faccessat("/afs/some/directory", 0) triggers a BUG in the permissions
    check code.
    
    Fix this by just removing the BUG section.  If no permissions are asked
    for, just return okay if the file exists.
    
    Also:
    
     (1) Split up the directory check so that it has separate if-statements
         rather than if-else-if (e.g. checking for MAY_EXEC shouldn't skip the
         check for MAY_READ and MAY_WRITE).
    
     (2) Check for MAY_CHDIR as MAY_EXEC.
    
    Without the main fix, the following BUG may occur:
    
     kernel BUG at fs/afs/security.c:386!
     invalid opcode: 0000 [#1] SMP PTI
     ...
     RIP: 0010:afs_permission+0x19d/0x1a0 [kafs]
     ...
     Call Trace:
      ? inode_permission+0xbe/0x180
      ? do_faccessat+0xdc/0x270
      ? do_syscall_64+0x60/0x1f0
      ? entry_SYSCALL_64_after_hwframe+0x49/0xbe
    
    Fixes: 00d3b7a4 ("[AFS]: Add security support.")
    Reported-by: default avatarJonathan Billings <jsbillings@jsbillings.org>
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    e36bc993
Name
Last commit
Last update
..
Kconfig Loading commit data...
Makefile Loading commit data...
afs.h Loading commit data...
afs_cm.h Loading commit data...
afs_fs.h Loading commit data...
afs_vl.h Loading commit data...
cache.c Loading commit data...
callback.c Loading commit data...
cell.c Loading commit data...
cmservice.c Loading commit data...
dir.c Loading commit data...
file.c Loading commit data...
flock.c Loading commit data...
fsclient.c Loading commit data...
inode.c Loading commit data...
internal.h Loading commit data...
main.c Loading commit data...
misc.c Loading commit data...
mntpt.c Loading commit data...
netdevices.c Loading commit data...
proc.c Loading commit data...
rxrpc.c Loading commit data...
security.c Loading commit data...
server.c Loading commit data...
super.c Loading commit data...
vlclient.c Loading commit data...
vlocation.c Loading commit data...
vnode.c Loading commit data...
volume.c Loading commit data...
write.c Loading commit data...
xattr.c Loading commit data...