Skip to content

Commit 8c78293

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull Integrity subsystem fix from James Morris: "These changes fix a bug in xattr handling, where the evm and ima inode_setxattr() functions do not check for empty xattrs being passed from userspace (leading to user-triggerable null pointer dereferences)" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: evm: check xattr value length and type in evm_inode_setxattr() ima: check xattr value length and type in the ima_inode_setxattr()
2 parents 19be9e8 + 6c880ad commit 8c78293

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

security/integrity/evm/evm_main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,12 @@ int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name,
319319
{
320320
const struct evm_ima_xattr_data *xattr_data = xattr_value;
321321

322-
if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0)
323-
&& (xattr_data->type == EVM_XATTR_HMAC))
324-
return -EPERM;
322+
if (strcmp(xattr_name, XATTR_NAME_EVM) == 0) {
323+
if (!xattr_value_len)
324+
return -EINVAL;
325+
if (xattr_data->type != EVM_IMA_XATTR_DIGSIG)
326+
return -EPERM;
327+
}
325328
return evm_protect_xattr(dentry, xattr_name, xattr_value,
326329
xattr_value_len);
327330
}

security/integrity/ima/ima_appraise.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
378378
result = ima_protect_xattr(dentry, xattr_name, xattr_value,
379379
xattr_value_len);
380380
if (result == 1) {
381+
if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST))
382+
return -EINVAL;
381383
ima_reset_appraise_flags(dentry->d_inode,
382384
(xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0);
383385
result = 0;

security/integrity/integrity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ enum evm_ima_xattr_type {
6161
EVM_XATTR_HMAC,
6262
EVM_IMA_XATTR_DIGSIG,
6363
IMA_XATTR_DIGEST_NG,
64+
IMA_XATTR_LAST
6465
};
6566

6667
struct evm_ima_xattr_data {

0 commit comments

Comments
 (0)