Skip to content

Commit 83a1e53

Browse files
devusr-sw-kimcschaufler
authored andcommitted
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>
1 parent 805b65a commit 83a1e53

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

security/smack/smack_lsm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,9 @@ static int smack_file_ioctl(struct file *file, unsigned int cmd,
16471647
struct smk_audit_info ad;
16481648
struct inode *inode = file_inode(file);
16491649

1650+
if (unlikely(IS_PRIVATE(inode)))
1651+
return 0;
1652+
16501653
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
16511654
smk_ad_setfield_u_fs_path(&ad, file->f_path);
16521655

@@ -1676,6 +1679,9 @@ static int smack_file_lock(struct file *file, unsigned int cmd)
16761679
int rc;
16771680
struct inode *inode = file_inode(file);
16781681

1682+
if (unlikely(IS_PRIVATE(inode)))
1683+
return 0;
1684+
16791685
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
16801686
smk_ad_setfield_u_fs_path(&ad, file->f_path);
16811687
rc = smk_curacc(smk_of_inode(inode), MAY_LOCK, &ad);
@@ -1702,6 +1708,9 @@ static int smack_file_fcntl(struct file *file, unsigned int cmd,
17021708
int rc = 0;
17031709
struct inode *inode = file_inode(file);
17041710

1711+
if (unlikely(IS_PRIVATE(inode)))
1712+
return 0;
1713+
17051714
switch (cmd) {
17061715
case F_GETLK:
17071716
break;
@@ -1755,6 +1764,9 @@ static int smack_mmap_file(struct file *file,
17551764
if (file == NULL)
17561765
return 0;
17571766

1767+
if (unlikely(IS_PRIVATE(file_inode(file))))
1768+
return 0;
1769+
17581770
isp = file_inode(file)->i_security;
17591771
if (isp->smk_mmap == NULL)
17601772
return 0;

0 commit comments

Comments
 (0)