Skip to content

Commit a41d80a

Browse files
Dan CarpenterMimi Zohar
authored andcommitted
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: 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]>
1 parent 72acd64 commit a41d80a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

security/integrity/evm/evm_secfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static ssize_t evm_write_xattrs(struct file *file, const char __user *buf,
209209

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

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

0 commit comments

Comments
 (0)