mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
NFSv4.2: Fix a memory stomp in decode_attr_security_label
[ Upstream commit43c1031f71] We must not change the value of label->len if it is zero, since that indicates we stored a label. Fixes:b4487b9354("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>
This commit is contained in:
@@ -4160,12 +4160,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;
|
||||
|
||||
Reference in New Issue
Block a user