From 306b09ff3be45cbcb8b506e06db03aaaa092483f Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Mon, 12 Dec 2016 17:35:26 +0900 Subject: [PATCH] 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 Signed-off-by: Casey Schaufler --- security/smack/smack_lsm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 0907c7f..91c7ab2 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1465,6 +1465,9 @@ static int smack_file_ioctl(struct file *file, unsigned int cmd, int rc = 0; struct smk_audit_info ad; + if (unlikely(IS_PRIVATE(file_inode(file)))) + return 0; + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); smk_ad_setfield_u_fs_path(&ad, file->f_path); @@ -1493,6 +1496,9 @@ static int smack_file_lock(struct file *file, unsigned int cmd) struct smk_audit_info ad; int rc; + if (unlikely(IS_PRIVATE(file_inode(file)))) + return 0; + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH); smk_ad_setfield_u_fs_path(&ad, file->f_path); rc = smk_curacc(file->f_security, MAY_LOCK, &ad); @@ -1518,6 +1524,8 @@ static int smack_file_fcntl(struct file *file, unsigned int cmd, struct smk_audit_info ad; int rc = 0; + if (unlikely(IS_PRIVATE(file_inode(file)))) + return 0; switch (cmd) { case F_GETLK: @@ -1571,6 +1579,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; -- 2.7.4