• J
    nfs: Fix security label length not being reset · ca70c18c
    Jeffrey Mitchell 提交于
    stable inclusion
    from linux-4.19.150
    commit 345c6f260c89e417de6e7d81f3366bd5079f48a3
    
    --------------------------------
    
    [ Upstream commit d33030e2 ]
    
    nfs_readdir_page_filler() iterates over entries in a directory, reusing
    the same security label buffer, but does not reset the buffer's length.
    This causes decode_attr_security_label() to return -ERANGE if an entry's
    security label is longer than the previous one's. This error, in
    nfs4_decode_dirent(), only gets passed up as -EAGAIN, which causes another
    failed attempt to copy into the buffer. The second error is ignored and
    the remaining entries do not show up in ls, specifically the getdents64()
    syscall.
    
    Reproduce by creating multiple files in NFS and giving one of the later
    files a longer security label. ls will not see that file nor any that are
    added afterwards, though they will exist on the backend.
    
    In nfs_readdir_page_filler(), reset security label buffer length before
    every reuse
    Signed-off-by: NJeffrey Mitchell <jeffrey.mitchell@starlab.io>
    Fixes: b4487b93 ("nfs: Fix getxattr kernel panic and memory overflow")
    Signed-off-by: NTrond Myklebust <trond.myklebust@hammerspace.com>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    ca70c18c
dir.c 66.6 KB