All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] security: fix dummy xattr functions
@ 2008-07-01 20:40 Miklos Szeredi
  2008-07-02  6:12 ` James Morris
  0 siblings, 1 reply; 8+ messages in thread
From: Miklos Szeredi @ 2008-07-01 20:40 UTC (permalink / raw)
  To: jmorris; +Cc: jjohansen, akpm, linux-security-module, linux-kernel

Hi James,

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

Thanks,
Miklos

----
From: Miklos Szeredi <mszeredi@suse.cz>

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)

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

end of thread, other threads:[~2008-07-02 12:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-01 20:40 [patch] security: fix dummy xattr functions Miklos Szeredi
2008-07-02  6:12 ` James Morris
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

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.