All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Smack: ignore private inode for file functions
@ 2016-12-12  8:35 Seung-Woo Kim
  2016-12-15 23:59 ` Casey Schaufler
  0 siblings, 1 reply; 2+ messages in thread
From: Seung-Woo Kim @ 2016-12-12  8:35 UTC (permalink / raw)
  To: linux-security-module, casey
  Cc: james.l.morris, serge, linux-kernel, sw0312.kim, kk.moon, jy0922.shim

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>
---
 security/smack/smack_lsm.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 1cb0602..e7f0bbe 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1632,6 +1632,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);
 
@@ -1661,6 +1664,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);
@@ -1687,6 +1693,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;
@@ -1740,6 +1749,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;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Smack: ignore private inode for file functions
  2016-12-12  8:35 [PATCH] Smack: ignore private inode for file functions Seung-Woo Kim
@ 2016-12-15 23:59 ` Casey Schaufler
  0 siblings, 0 replies; 2+ messages in thread
From: Casey Schaufler @ 2016-12-15 23:59 UTC (permalink / raw)
  To: Seung-Woo Kim, linux-security-module
  Cc: james.l.morris, serge, linux-kernel, kk.moon, jy0922.shim

On 12/12/2016 12:35 AM, Seung-Woo Kim wrote:
> 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>

Acked-by: Casey Schaufler <casey@schaufler-ca.com>

I have queued this for my 4.11 tree.

> ---
>  security/smack/smack_lsm.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 1cb0602..e7f0bbe 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -1632,6 +1632,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);
>  
> @@ -1661,6 +1664,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);
> @@ -1687,6 +1693,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;
> @@ -1740,6 +1749,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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-15 23:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-12  8:35 [PATCH] Smack: ignore private inode for file functions Seung-Woo Kim
2016-12-15 23:59 ` Casey Schaufler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.