• Hou Tao's avatar
    jffs2: return -ERANGE when xattr buffer is too small · 5ac147eb
    Hou Tao authored
    When a file have multiple xattrs and the passed buffer is
    smaller than the required size, jffs2_listxattr() should
    return -ERANGE instead of continue, else Oops may occur
    due to memory corruption.
    
    Also remove the unnecessary check ("rc < 0"), because
    xhandle->list(...) will not return an error number.
    
    Spotted by generic/377 in xfstests-dev.
    
    NB: The problem had been fixed by commit 764a5c6b ("xattr
    handlers: Simplify list operation") in v4.5-rc1, but the
    modification in that commit may be too much because it modifies
    all file-systems which implement xattr, so I create a single
    patch for jffs2 to fix the problem.
    Signed-off-by: default avatarHou Tao <houtao1@huawei.com>
    Cc: David Woodhouse <dwmw2@infradead.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    5ac147eb
xattr.c 38.2 KB