Smack: Fix setting label on successful file open
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Tue, 19 Aug 2014 12:26:32 +0000 (14:26 +0200)
committerCasey Schaufler <casey@schaufler-ca.com>
Mon, 25 Aug 2014 21:27:28 +0000 (14:27 -0700)
While opening with CAP_MAC_OVERRIDE file label is not set.
Other calls may access it after CAP_MAC_OVERRIDE is dropped from process.

Signed-off-by: Marcin Niesluchowski <m.niesluchow@samsung.com>
security/smack/smack_lsm.c

index 16ae8534b14c5fb5a42c3123c2f33b8f50ad5fad..7091b46adab2fe7812664a8ceae7a5f409d59812 100644 (file)
@@ -1477,8 +1477,10 @@ static int smack_file_open(struct file *file, const struct cred *cred)
        struct smk_audit_info ad;
        int rc;
 
-       if (smack_privileged(CAP_MAC_OVERRIDE))
+       if (smack_privileged(CAP_MAC_OVERRIDE)) {
+               file->f_security = isp->smk_inode;
                return 0;
+       }
 
        smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
        smk_ad_setfield_u_fs_path(&ad, file->f_path);