Skip to content

Commit

Permalink
EVM: prevent array underflow in evm_write_xattrs()
Browse files Browse the repository at this point in the history
If the user sets xattr->name[0] to NUL then we would read one character
before the start of the array.  This bug seems harmless as far as I can
see but perhaps it would trigger a warning in KASAN.

Fixes: fa516b6 ("EVM: Allow runtime modification of the set of verified xattrs")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Mimi Zohar <[email protected]>
  • Loading branch information
Dan Carpenter authored and Mimi Zohar committed May 31, 2018
1 parent 72acd64 commit a41d80a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion security/integrity/evm/evm_secfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,

/* Remove any trailing newline */
len = strlen(xattr->name);
if (xattr->name[len-1] == '\n')
if (len && xattr->name[len-1] == '\n')
xattr->name[len-1] = '\0';

if (strcmp(xattr->name, ".") == 0) {
Expand Down

0 comments on commit a41d80a

Please sign in to comment.