Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a41d80ac authored by Dan Carpenter's avatar Dan Carpenter Committed by Mimi Zohar
Browse files

EVM: prevent array underflow in evm_write_xattrs()



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: fa516b66 ("EVM: Allow runtime modification of the set of verified xattrs")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.vnet.ibm.com>
parent 72acd64d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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) {