diff options
author | Trond Myklebust <trond.myklebust@hammerspace.com> | 2022-10-18 18:21:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-01-18 11:30:13 +0100 |
commit | 7e79794be1c1f96a395a317898a6639c803c2f0c (patch) | |
tree | b423e226e8765d1afd828d8cfcc2b258a82a8b7d /fs/nfs | |
parent | 00e875d200342cc4441ff66470fe14ef29b66e84 (diff) | |
download | linux-stable-7e79794be1c1f96a395a317898a6639c803c2f0c.tar.gz linux-stable-7e79794be1c1f96a395a317898a6639c803c2f0c.tar.bz2 linux-stable-7e79794be1c1f96a395a317898a6639c803c2f0c.zip |
NFSv4.2: Fix a memory stomp in decode_attr_security_label
[ Upstream commit 43c1031f7110967c240cb6e922adcfc4b8899183 ]
We must not change the value of label->len if it is zero, since that
indicates we stored a label.
Fixes: b4487b935452 ("nfs: Fix getxattr kernel panic and memory overflow")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/nfs4xdr.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 56e48642c43e..f0021e3b8efd 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -4277,12 +4277,10 @@ static int decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap, if (unlikely(!p)) goto out_overflow; if (len < NFS4_MAXLABELLEN) { - if (label) { - if (label->len) { - if (label->len < len) - return -ERANGE; - memcpy(label->label, p, len); - } + if (label && label->len) { + if (label->len < len) + return -ERANGE; + memcpy(label->label, p, len); label->len = len; label->pi = pi; label->lfs = lfs; |