Skip to content

Commit 14793a8

Browse files
XidianGeneralgregkh
authored andcommitted
fs: nfs: Fix possible null-pointer dereferences in encode_attrs()
[ Upstream commit e275146 ] In encode_attrs(), there is an if statement on line 1145 to check whether label is NULL: if (label && (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL)) When label is NULL, it is used on lines 1178-1181: *p++ = cpu_to_be32(label->lfs); *p++ = cpu_to_be32(label->pi); *p++ = cpu_to_be32(label->len); p = xdr_encode_opaque_fixed(p, label->label, label->len); To fix these bugs, label is checked before being used. These bugs are found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai <[email protected]> Signed-off-by: Anna Schumaker <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 1e42dec commit 14793a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/nfs/nfs4xdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
11231123
} else
11241124
*p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
11251125
}
1126-
if (bmval[2] & FATTR4_WORD2_SECURITY_LABEL) {
1126+
if (label && (bmval[2] & FATTR4_WORD2_SECURITY_LABEL)) {
11271127
*p++ = cpu_to_be32(label->lfs);
11281128
*p++ = cpu_to_be32(label->pi);
11291129
*p++ = cpu_to_be32(label->len);

0 commit comments

Comments
 (0)