Skip to content

Commit 7d3e91a

Browse files
swegenerTrond Myklebust
authored andcommitted
NFSv4: Check for buffer length in __nfs4_get_acl_uncached
Commit 1f1ea6c "NFSv4: Fix buffer overflow checking in __nfs4_get_acl_uncached" accidently dropped the checking for too small result buffer length. If someone uses getxattr on "system.nfs4_acl" on an NFSv4 mount supporting ACLs, the ACL has not been cached and the buffer suplied is too short, we still copy the complete ACL, resulting in kernel and user space memory corruption. Signed-off-by: Sven Wegener <sven.wegener@stealer.net> Cc: stable@kernel.org Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 4c10021 commit 7d3e91a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎fs/nfs/nfs4proc.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3937,8 +3937,13 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
39373937
goto out_free;
39383938
}
39393939
nfs4_write_cached_acl(inode, pages, res.acl_data_offset, res.acl_len);
3940-
if (buf)
3940+
if (buf) {
3941+
if (res.acl_len > buflen) {
3942+
ret = -ERANGE;
3943+
goto out_free;
3944+
}
39413945
_copy_from_pages(buf, pages, res.acl_data_offset, res.acl_len);
3946+
}
39423947
out_ok:
39433948
ret = res.acl_len;
39443949
out_free:

0 commit comments

Comments
 (0)