Skip to content

Commit 43c1031

Browse files
author
Trond Myklebust
committed
NFSv4.2: Fix a memory stomp in decode_attr_security_label
We must not change the value of label->len if it is zero, since that indicates we stored a label. Fixes: b4487b9 ("nfs: Fix getxattr kernel panic and memory overflow") Signed-off-by: Trond Myklebust <[email protected]>
1 parent c8a62f4 commit 43c1031

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

fs/nfs/nfs4xdr.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4236,12 +4236,10 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
42364236
return -EIO;
42374237
bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
42384238
if (len < NFS4_MAXLABELLEN) {
4239-
if (label) {
4240-
if (label->len) {
4241-
if (label->len < len)
4242-
return -ERANGE;
4243-
memcpy(label->label, p, len);
4244-
}
4239+
if (label && label->len) {
4240+
if (label->len < len)
4241+
return -ERANGE;
4242+
memcpy(label->label, p, len);
42454243
label->len = len;
42464244
label->pi = pi;
42474245
label->lfs = lfs;

0 commit comments

Comments
 (0)