Smack: Fix setting label on successful file open 98/31098/1
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Tue, 19 Aug 2014 12:26:32 +0000 (14:26 +0200)
committerZbigniew Jasinski <z.jasinski@samsung.com>
Fri, 28 Nov 2014 09:36:57 +0000 (10:36 +0100)
While opening with CAP_MAC_OVERRIDE file label is not set.
Other calls may access it after CAP_MAC_OVERRIDE is dropped from process.

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

index 78f0925..28855d6 100644 (file)
@@ -1478,8 +1478,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);