mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Morris <jmorris@namei.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: jjohansen@suse.de, Andrew Morton <akpm@linux-foundation.org>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Serge E. Hallyn" <serue@us.ibm.com>,
	"Andrew G. Morgan" <morgan@kernel.org>
Subject: Re: [patch] security: fix dummy xattr functions
Date: Wed, 2 Jul 2008 16:12:44 +1000 (EST)	[thread overview]
Message-ID: <Xine.LNX.4.64.0807021604120.26138@us.intercode.com.au> (raw)
In-Reply-To: <E1KDmeW-0006KB-2x@pomaz-ex.szeredi.hu>

On Tue, 1 Jul 2008, Miklos Szeredi wrote:

> Hi James,
> 
> If this (untested) patch looks OK, could you please apply it to your
> tree?

As I understand it, filesystem capabilities is only enabled when either 
LSM is disabled, or the LSM capabilities module is built.

In both cases, security/commoncap.o is built.  With LSM disabled, the 
correct cap_inode_xxx functions will be linked.  With LSM+capabilities, 
either the capability LSM will be loaded, or another LSM will need to 
deliberately stack it.

So, I think the existing code is correct.

> 
> Replace open coded xattr checks with cap_inode_xxx() function calls in
> dummy_inode_setxattr() and dummy_inode_removexattr().  The old ones
> were out of sync with the cap_inode_xxx() implementation, which could
> even be a security problem.
> 
> Noticed by John Johansen.
> 
> CC: John Johansen <jjohansen@suse.de>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
> ---
>  security/dummy.c |   12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> Index: linux-2.6/security/dummy.c
> ===================================================================
> --- linux-2.6.orig/security/dummy.c	2008-07-01 21:44:03.000000000 +0200
> +++ linux-2.6/security/dummy.c	2008-07-01 21:51:08.000000000 +0200
> @@ -370,11 +370,7 @@ static void dummy_inode_delete (struct i
>  static int dummy_inode_setxattr (struct dentry *dentry, const char *name,
>  				 const void *value, size_t size, int flags)
>  {
> -	if (!strncmp(name, XATTR_SECURITY_PREFIX,
> -		     sizeof(XATTR_SECURITY_PREFIX) - 1) &&
> -	    !capable(CAP_SYS_ADMIN))
> -		return -EPERM;
> -	return 0;
> +	return cap_inode_setxattr(dentry, name, value, size, flags);
>  }
>  
>  static void dummy_inode_post_setxattr (struct dentry *dentry, const char *name,
> @@ -395,11 +391,7 @@ static int dummy_inode_listxattr (struct
>  
>  static int dummy_inode_removexattr (struct dentry *dentry, const char *name)
>  {
> -	if (!strncmp(name, XATTR_SECURITY_PREFIX,
> -		     sizeof(XATTR_SECURITY_PREFIX) - 1) &&
> -	    !capable(CAP_SYS_ADMIN))
> -		return -EPERM;
> -	return 0;
> +	return cap_inode_removexattr(dentry, name);
>  }
>  
>  static int dummy_inode_need_killpriv(struct dentry *dentry)
> 

-- 
James Morris
<jmorris@namei.org>

  reply	other threads:[~2008-07-02  6:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-01 20:40 Miklos Szeredi
2008-07-02  6:12 ` James Morris [this message]
2008-07-02  7:22   ` Miklos Szeredi
2008-07-02  9:16     ` James Morris
2008-07-02  9:28       ` Miklos Szeredi
2008-07-02 11:48       ` Stephen Smalley
2008-07-02 11:54         ` Miklos Szeredi
2008-07-02 12:28           ` Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Xine.LNX.4.64.0807021604120.26138@us.intercode.com.au \
    --to=jmorris@namei.org \
    --cc=akpm@linux-foundation.org \
    --cc=jjohansen@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=morgan@kernel.org \
    --cc=serue@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®