From: Chris Wright <chrisw@osdl.org>
To: akpm@osdl.org, torvalds@osdl.org
Cc: Andreas Gruenbacher <agruen@suse.de>,
Michael Kerrisk <michael.kerrisk@gmx.net>,
Stephen Smalley <sds@epoch.ncsc.mil>,
linux-kernel@vger.kernel.org, linux-security-module@wirex.com
Subject: [PATCH 2/2] Default hooks protecting the XATTR_SECURITY_PREFIX namespace
Date: Fri, 16 Jan 2004 13:20:04 -0800 [thread overview]
Message-ID: <20040116132004.R19023@osdlab.pdx.osdl.net> (raw)
In-Reply-To: <20040116131423.Q19023@osdlab.pdx.osdl.net>; from chrisw@osdl.org on Fri, Jan 16, 2004 at 01:14:23PM -0800
Add default hooks for both the dummy and capability code to protect the
XATTR_SECURITY_PREFIX namespace. These EAs were fully accessible to
unauthorized users, so a user that rebooted from an SELinux kernel to a
default kernel would leave those critical EAs unprotected.
include/linux/security.h | 6 ++++--
security/capability.c | 3 +++
security/commoncap.c | 22 ++++++++++++++++++++++
security/dummy.c | 9 +++++++++
4 files changed, 38 insertions(+), 2 deletions(-)
===== include/linux/security.h 1.26 vs edited =====
--- 1.26/include/linux/security.h Thu Oct 2 00:12:10 2003
+++ edited/include/linux/security.h Fri Jan 16 12:14:15 2004
@@ -46,6 +46,8 @@
extern int cap_bprm_set_security (struct linux_binprm *bprm);
extern void cap_bprm_compute_creds (struct linux_binprm *bprm);
extern int cap_bprm_secureexec(struct linux_binprm *bprm);
+extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
+extern int cap_inode_removexattr(struct dentry *dentry, char *name);
extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
extern void cap_task_reparent_to_init (struct task_struct *p);
extern int cap_syslog (int type);
@@ -2136,7 +2138,7 @@
static inline int security_inode_setxattr (struct dentry *dentry, char *name,
void *value, size_t size, int flags)
{
- return 0;
+ return cap_inode_setxattr(dentry, name, value, size, flags);
}
static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
@@ -2155,7 +2157,7 @@
static inline int security_inode_removexattr (struct dentry *dentry, char *name)
{
- return 0;
+ return cap_inode_removexattr(dentry, name);
}
static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size)
===== security/capability.c 1.21 vs edited =====
--- 1.21/security/capability.c Fri Sep 12 08:47:26 2003
+++ edited/security/capability.c Fri Jan 16 12:14:15 2004
@@ -39,6 +39,9 @@
.bprm_set_security = cap_bprm_set_security,
.bprm_secureexec = cap_bprm_secureexec,
+ .inode_setxattr = cap_inode_setxattr,
+ .inode_removexattr = cap_inode_removexattr,
+
.task_post_setuid = cap_task_post_setuid,
.task_reparent_to_init = cap_task_reparent_to_init,
===== security/commoncap.c 1.1 vs edited =====
--- 1.1/security/commoncap.c Fri Sep 12 08:47:26 2003
+++ edited/security/commoncap.c Fri Jan 16 12:14:15 2004
@@ -21,6 +21,7 @@
#include <linux/skbuff.h>
#include <linux/netlink.h>
#include <linux/ptrace.h>
+#include <linux/xattr.h>
int cap_capable (struct task_struct *tsk, int cap)
{
@@ -171,6 +172,25 @@
current->egid != current->gid);
}
+int cap_inode_setxattr(struct dentry *dentry, char *name, 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;
+}
+
+int cap_inode_removexattr(struct dentry *dentry, char *name)
+{
+ if (!strncmp(name, XATTR_SECURITY_PREFIX,
+ sizeof(XATTR_SECURITY_PREFIX) - 1) &&
+ !capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ return 0;
+}
+
/* moved from kernel/sys.c. */
/*
* cap_emulate_setxuid() fixes the effective / permitted capabilities of
@@ -344,6 +364,8 @@
EXPORT_SYMBOL(cap_bprm_set_security);
EXPORT_SYMBOL(cap_bprm_compute_creds);
EXPORT_SYMBOL(cap_bprm_secureexec);
+EXPORT_SYMBOL(cap_inode_setxattr);
+EXPORT_SYMBOL(cap_inode_removexattr);
EXPORT_SYMBOL(cap_task_post_setuid);
EXPORT_SYMBOL(cap_task_reparent_to_init);
EXPORT_SYMBOL(cap_syslog);
===== security/dummy.c 1.28 vs edited =====
--- 1.28/security/dummy.c Thu Oct 2 00:12:10 2003
+++ edited/security/dummy.c Fri Jan 16 12:29:24 2004
@@ -24,6 +24,7 @@
#include <linux/skbuff.h>
#include <linux/netlink.h>
#include <net/sock.h>
+#include <linux/xattr.h>
static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
{
@@ -387,6 +388,10 @@
static int dummy_inode_setxattr (struct dentry *dentry, char *name, 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;
}
@@ -407,6 +412,10 @@
static int dummy_inode_removexattr (struct dentry *dentry, char *name)
{
+ if (!strncmp(name, XATTR_SECURITY_PREFIX,
+ sizeof(XATTR_SECURITY_PREFIX) - 1) &&
+ !capable(CAP_SYS_ADMIN))
+ return -EPERM;
return 0;
}
next prev parent reply other threads:[~2004-01-16 21:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-16 21:14 [PATCH 1/2] Move XATTR_SECURITY_PREFIX macro to common location Chris Wright
2004-01-16 21:20 ` Chris Wright [this message]
2004-01-16 23:37 ` [PATCH 2/2] Default hooks protecting the XATTR_SECURITY_PREFIX namespace Andreas Gruenbacher
2004-01-17 16:41 ` Theodore Ts'o
2004-01-19 18:25 ` Chris Wright
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=20040116132004.R19023@osdlab.pdx.osdl.net \
--to=chrisw@osdl.org \
--cc=agruen@suse.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@wirex.com \
--cc=michael.kerrisk@gmx.net \
--cc=sds@epoch.ncsc.mil \
--cc=torvalds@osdl.org \
/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
Powered by JetHome