Skip to content

Commit 58fcb8d

Browse files
Trond MyklebustLinus Torvalds
authored andcommitted
[PATCH] NFS: Ensure ACL xdr code doesn't overflow.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 75cd968 commit 58fcb8d

3 files changed

Lines changed: 3 additions & 0 deletions

File tree

‎fs/nfs_common/nfsacl.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
239239
if (xdr_decode_word(buf, base, &entries) ||
240240
entries > NFS_ACL_MAX_ENTRIES)
241241
return -EINVAL;
242+
nfsacl_desc.desc.array_maxlen = entries;
242243
err = xdr_decode_array2(buf, base + 4, &nfsacl_desc.desc);
243244
if (err)
244245
return err;

‎include/linux/sunrpc/xdr.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ typedef int (*xdr_xcode_elem_t)(struct xdr_array2_desc *desc, void *elem);
177177
struct xdr_array2_desc {
178178
unsigned int elem_size;
179179
unsigned int array_len;
180+
unsigned int array_maxlen;
180181
xdr_xcode_elem_t xcode;
181182
};
182183

‎net/sunrpc/xdr.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,7 @@ xdr_xcode_array2(struct xdr_buf *buf, unsigned int base,
993993
return -EINVAL;
994994
} else {
995995
if (xdr_decode_word(buf, base, &desc->array_len) != 0 ||
996+
desc->array_len > desc->array_maxlen ||
996997
(unsigned long) base + 4 + desc->array_len *
997998
desc->elem_size > buf->len)
998999
return -EINVAL;

0 commit comments

Comments
 (0)