evm: properly handle INTEGRITY_NOXATTRS EVM status
authorDmitry Kasatkin <d.kasatkin@samsung.com>
Tue, 2 Sep 2014 13:31:43 +0000 (16:31 +0300)
committerMimi Zohar <zohar@linux.vnet.ibm.com>
Tue, 9 Sep 2014 14:26:10 +0000 (10:26 -0400)
Unless an LSM labels a file during d_instantiate(), newly created
files are not labeled with an initial security.evm xattr, until
the file closes.  EVM, before allowing a protected, security xattr
to be written, verifies the existing 'security.evm' value is good.
For newly created files without a security.evm label, this
verification prevents writing any protected, security xattrs,
until the file closes.

Following is the example when this happens:
fd = open("foo", O_CREAT | O_WRONLY, 0644);
setxattr("foo", "security.SMACK64", value, sizeof(value), 0);
close(fd);

While INTEGRITY_NOXATTRS status is handled in other places, such
as evm_inode_setattr(), it does not handle it in all cases in
evm_protect_xattr().  By limiting the use of INTEGRITY_NOXATTRS to
newly created files, we can now allow setting "protected" xattrs.

Changelog:
- limit the use of INTEGRITY_NOXATTRS to IMA identified new files

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: <stable@vger.kernel.org> 3.14+
security/integrity/evm/evm_main.c

index 40220124364caa075019cef979a4a13387955835..9685af330de5db40f4d7d097ea736b377dd68b36 100644 (file)
@@ -285,6 +285,13 @@ static int evm_protect_xattr(struct dentry *dentry, const char *xattr_name,
                goto out;
        }
        evm_status = evm_verify_current_integrity(dentry);
+       if (evm_status == INTEGRITY_NOXATTRS) {
+               struct integrity_iint_cache *iint;
+
+               iint = integrity_iint_find(dentry->d_inode);
+               if (iint && (iint->flags & IMA_NEW_FILE))
+                       return 0;
+       }
 out:
        if (evm_status != INTEGRITY_PASS)
                integrity_audit_msg(AUDIT_INTEGRITY_METADATA, dentry->d_inode,
This page took 0.02878 seconds and 5 git commands to generate.