提交 a41d80ac 编写于 作者: D Dan Carpenter 提交者: Mimi Zohar

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: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
上级 72acd64d
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册