From: Michael Halcrow <mhalcrow@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, Chris Wright <chrisw@osdl.org>,
Serge Hallyn <serue@us.ibm.com>,
mhalcrow@us.ibm.com
Subject: [updated patch 3/7] BSD Secure Levels: allow suid and sgid on directories
Date: Fri, 20 May 2005 10:06:33 -0500 [thread overview]
Message-ID: <20050520150632.GB5534@halcrow.us> (raw)
In-Reply-To: <20050519205525.GB16215@halcrow.us>
This patch is applies cleanly against the new printk() patch. It
allows setuid and setgid on directories. It also disallows the
creation of setuid/setgid executables via open or mknod.
Signed off by: Michael Halcrow <mhalcrow@us.ibm.com>
Index: linux-2.6.12-rc4-mm2-seclvl/security/seclvl.c
===================================================================
--- linux-2.6.12-rc4-mm2-seclvl.orig/security/seclvl.c 2005-05-19 17:46:13.000000000 -0500
+++ linux-2.6.12-rc4-mm2-seclvl/security/seclvl.c 2005-05-20 09:09:03.000000000 -0500
@@ -582,7 +582,11 @@
static int seclvl_inode_setattr(struct dentry *dentry, struct iattr *iattr)
{
if (seclvl > 0) {
- if (iattr->ia_valid & ATTR_MODE)
+ if (dentry && dentry->d_inode
+ && S_ISDIR(dentry->d_inode->i_mode)) {
+ return 0;
+ }
+ if (iattr && iattr->ia_valid & ATTR_MODE)
if (iattr->ia_mode & S_ISUID ||
iattr->ia_mode & S_ISGID) {
seclvl_printk(1, KERN_WARNING, "Attempt to "
@@ -596,6 +600,34 @@
}
/**
+ * Prevent an end-run around the inode_setattr control.
+ */
+static int seclvl_inode_mknod(struct inode *inode, struct dentry *dentry,
+ int mode, dev_t dev)
+{
+ if (seclvl > 0 && (mode & 02000 || mode & 04000)) {
+ seclvl_printk(1, KERN_WARNING, "Attempt to mknod with suid "
+ "or guid bit set in seclvl [%d]\n", seclvl);
+ return -EPERM;
+ }
+ return 0;
+}
+
+/**
+ * Prevent an end-run around the inode_setattr control.
+ */
+static int
+seclvl_inode_create(struct inode *inode, struct dentry *dentry, int mask)
+{
+ if (seclvl > 0 && (mask & 02000 || mask & 04000)) {
+ seclvl_printk(1, KERN_WARNING, "Attempt to create inode with "
+ "suid or guid bit set in seclvl [%d]\n", seclvl);
+ return -EPERM;
+ }
+ return 0;
+}
+
+/**
* Release busied block devices.
*/
static void seclvl_file_free_security(struct file *filp)
@@ -630,6 +662,8 @@
.file_permission = seclvl_file_permission,
.file_mmap = seclvl_file_mmap,
.inode_setattr = seclvl_inode_setattr,
+ .inode_mknod = seclvl_inode_mknod,
+ .inode_create = seclvl_inode_create,
.file_free_security = seclvl_file_free_security,
.settime = seclvl_settime,
.sb_umount = seclvl_umount,
next prev parent reply other threads:[~2005-05-20 15:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-17 15:23 [patch 1/7] BSD Secure Levels: printk overhaul Michael Halcrow
2005-05-17 15:25 ` [patch 2/7] BSD Secure Levels: move bd claim from inode to filp Michael Halcrow
2005-05-17 16:09 ` Christoph Hellwig
2005-05-17 16:49 ` Al Viro
2005-05-17 16:57 ` Al Viro
2005-05-17 19:46 ` Michael Halcrow
2005-05-17 20:13 ` Al Viro
2005-05-17 15:26 ` [patch 3/7] BSD Secure Levels: allow suid and sgid on directories Michael Halcrow
2005-05-17 15:27 ` [patch 4/7] BSD Secure Levels: memory alloc failure check Michael Halcrow
2005-05-17 17:27 ` Alexey Dobriyan
2005-05-17 15:30 ` [patch 5/7] BSD Secure Levels: allow setuid/setgid on root user processes Michael Halcrow
2005-05-17 15:31 ` [patch 6/7] BSD Secure Levels: trivial code and comment changes Michael Halcrow
2005-05-17 15:31 ` [patch 7/7] BSD Secure Levels: remove redundant ptrace check Michael Halcrow
2005-05-17 17:33 ` [patch 1/7] BSD Secure Levels: printk overhaul dean gaudet
2005-05-19 1:29 ` Dave Hansen
2005-05-19 10:39 ` Bernd Petrovitsch
2005-05-19 20:55 ` [updated patch " Michael Halcrow
2005-05-19 21:41 ` Michael Halcrow
2005-05-20 5:19 ` aq
2005-05-20 15:03 ` [updated patch 2/7] BSD Secure Levels: bd_claim fixes Michael Halcrow
2005-05-20 15:06 ` Michael Halcrow [this message]
2005-05-20 15:09 ` [updated patch 4/7] BSD Secure Levels: memory alloc failure check Michael Halcrow
2005-05-20 15:10 ` [updated patch 5/7] BSD Secure Levels: allow setuid/setgid on root user processes Michael Halcrow
2005-05-20 15:13 ` [updated patch 6/7] BSD Secure Levels: trivial code and comment changes Michael Halcrow
2005-05-20 15:15 ` [updated patch 7/7] BSD Secure Levels: remove redundant ptrace check Michael Halcrow
2005-05-20 15:20 ` [patch 8/7] BSD Secure Levels: unregister on sysfs failure Michael Halcrow
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=20050520150632.GB5534@halcrow.us \
--to=mhalcrow@us.ibm.com \
--cc=akpm@osdl.org \
--cc=chrisw@osdl.org \
--cc=linux-kernel@vger.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
Powered by JetHome