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)
committerDamian Hobson-Garcia <dhobsong@igel.co.jp>
Thu, 11 Dec 2014 07:53:32 +0000 (16:53 +0900)
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: I937d070e1c0cb251f4a0dd3291efbc94be3ca548
Signed-off-by: Marcin Niesluchowski <m.niesluchow@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Origin: git://git.gitorious.org/smack-next/kernel.git# smack-for-3.18
(cherry picked from commit 6047a807302a008d48bd2a4822025b725580c361)

Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
security/smack/smack_lsm.c

index d347b79..47ed6a4 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);