Skip to content

Commit 70946c4

Browse files
saschahauerMimi Zohar
authored andcommitted
evm: check for remount ro in progress before writing
EVM might update the evm xattr while the VFS performs a remount to readonly mode. This is not properly checked for, additionally check the s_readonly_remount superblock flag before writing. The bug can for example be observed with UBIFS. UBIFS checks the free space on the device before and after a remount. With EVM enabled the free space sometimes differs between both checks. Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent f5e51fa commit 70946c4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

security/integrity/evm/evm_main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
124124
struct evm_ima_xattr_data *xattr_data = NULL;
125125
struct evm_ima_xattr_data calc;
126126
enum integrity_status evm_status = INTEGRITY_PASS;
127+
struct inode *inode;
127128
int rc, xattr_len;
128129

129130
if (iint && (iint->evm_status == INTEGRITY_PASS ||
@@ -178,12 +179,15 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
178179
(const char *)xattr_data, xattr_len,
179180
calc.digest, sizeof(calc.digest));
180181
if (!rc) {
182+
inode = d_backing_inode(dentry);
183+
181184
if (xattr_data->type == EVM_XATTR_PORTABLE_DIGSIG) {
182185
if (iint)
183186
iint->flags |= EVM_IMMUTABLE_DIGSIG;
184187
evm_status = INTEGRITY_PASS_IMMUTABLE;
185-
} else if (!IS_RDONLY(d_backing_inode(dentry)) &&
186-
!IS_IMMUTABLE(d_backing_inode(dentry))) {
188+
} else if (!IS_RDONLY(inode) &&
189+
!(inode->i_sb->s_readonly_remount) &&
190+
!IS_IMMUTABLE(inode)) {
187191
evm_update_evmxattr(dentry, xattr_name,
188192
xattr_value,
189193
xattr_value_len);

0 commit comments

Comments
 (0)