summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-12 17:35:26 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2019-01-09 05:04:32 +0000
commit7ef50f7925cf38f5ed567d59f436c3326b244153 (patch)
treef0b512833e6ea233ad869ab865e544edf1dde226
parent2b0745ba11e651024d9529817b1e7dbcffd34c22 (diff)
downloadlinux-4.9-exynos9110-7ef50f7925cf38f5ed567d59f436c3326b244153.tar.gz
linux-4.9-exynos9110-7ef50f7925cf38f5ed567d59f436c3326b244153.tar.bz2
linux-4.9-exynos9110-7ef50f7925cf38f5ed567d59f436c3326b244153.zip
Smack: ignore private inode for file functions
The access to fd from anon_inode is always failed because there is no set xattr operations. So this patch fixes to ignore private inode including anon_inode for file functions. It was only ignored for smack_file_receive() to share dma-buf fd, but dma-buf has other functions like ioctl and mmap. Reference: https://lkml.org/lkml/2015/4/17/16 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> [sw0312.kim: backport mainline commit 83a1e53f3920 for Tizen security smack] Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com> Change-Id: I31719d13885b63ebd643fe03565314ad7d65ee3c
-rw-r--r--security/smack/smack_lsm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index cd64a5ba5843..22d84b450ac6 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1627,6 +1627,9 @@ static int smack_file_ioctl(struct file *file, unsigned int cmd,
struct smk_audit_info ad;
struct inode *inode = file_inode(file);
+ if (unlikely(IS_PRIVATE(inode)))
+ return 0;
+
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
smk_ad_setfield_u_fs_path(&ad, file->f_path);
@@ -1656,6 +1659,9 @@ static int smack_file_lock(struct file *file, unsigned int cmd)
int rc;
struct inode *inode = file_inode(file);
+ if (unlikely(IS_PRIVATE(inode)))
+ return 0;
+
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
smk_ad_setfield_u_fs_path(&ad, file->f_path);
rc = smk_curacc(smk_of_inode(inode), MAY_LOCK, &ad);
@@ -1682,6 +1688,9 @@ static int smack_file_fcntl(struct file *file, unsigned int cmd,
int rc = 0;
struct inode *inode = file_inode(file);
+ if (unlikely(IS_PRIVATE(inode)))
+ return 0;
+
switch (cmd) {
case F_GETLK:
break;
@@ -1735,6 +1744,9 @@ static int smack_mmap_file(struct file *file,
if (file == NULL)
return 0;
+ if (unlikely(IS_PRIVATE(file_inode(file))))
+ return 0;
+
isp = file_inode(file)->i_security;
if (isp->smk_mmap == NULL)
return 0;