Skip to content

Commit 72acd64

Browse files
Colin Ian KingMimi Zohar
authored andcommitted
EVM: Fix null dereference on xattr when xattr fails to allocate
In the case where the allocation of xattr fails and xattr is NULL, the error exit return path via label 'out' will dereference xattr when kfree'ing xattr-name. Fix this by only kfree'ing xattr->name and xattr when xattr is non-null. Detected by CoverityScan, CID#1469366 ("Dereference after null check") Fixes: fa516b6 ("EVM: Allow runtime modification of the set of verified xattrs") Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 825b865 commit 72acd64

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

security/integrity/evm/evm_secfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,10 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,
253253
out:
254254
audit_log_format(ab, " res=%d", err);
255255
audit_log_end(ab);
256-
kfree(xattr->name);
257-
kfree(xattr);
256+
if (xattr) {
257+
kfree(xattr->name);
258+
kfree(xattr);
259+
}
258260
return err;
259261
}
260262

0 commit comments

Comments
 (0)