From: "Stephen D. Smalley" <sds@epoch.ncsc.mil>
To: linux-kernel@vger.kernel.org
Cc: linux-security-module@wirex.com, sds@epoch.ncsc.mil
Subject: [RFC][PATCH] Add LSM sysctl hook to 2.5.59
Date: Fri, 17 Jan 2003 16:54:37 -0500 (EST) [thread overview]
Message-ID: <200301172154.QAA00757@moss-shockers.ncsc.mil> (raw)
This patch adds a LSM sysctl hook for controlling access to
sysctl variables to 2.5.59, split out from the lsm-2.5 BitKeeper tree.
SELinux uses this hook to control such accesses in accordance with the
security policy configuration.
If anyone has any objections to this change, please let me know.
include/linux/security.h | 17 +++++++++++++++++
kernel/sysctl.c | 5 +++++
security/dummy.c | 6 ++++++
3 files changed, 28 insertions(+)
-----
===== include/linux/security.h 1.9 vs edited =====
--- 1.9/include/linux/security.h Wed Dec 18 09:10:50 2002
+++ edited/include/linux/security.h Fri Jan 17 14:49:12 2003
@@ -771,6 +771,12 @@
* is NULL.
* @file contains the file structure for the accounting file (may be NULL).
* Return 0 if permission is granted.
+ * @sysctl:
+ * Check permission before accessing the @table sysctl variable in the
+ * manner specified by @op.
+ * @table contains the ctl_table structure for the sysctl variable.
+ * @op contains the operation (001 = search, 002 = write, 004 = read).
+ * Return 0 if permission is granted.
* @capable:
* Check whether the @tsk process has the @cap capability.
* @tsk contains the task_struct for the process.
@@ -802,6 +808,7 @@
kernel_cap_t * inheritable,
kernel_cap_t * permitted);
int (*acct) (struct file * file);
+ int (*sysctl) (ctl_table * table, int op);
int (*capable) (struct task_struct * tsk, int cap);
int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
int (*quota_on) (struct file * f);
@@ -992,6 +999,11 @@
return security_ops->acct (file);
}
+static inline int security_sysctl(ctl_table * table, int op)
+{
+ return security_ops->sysctl(table, op);
+}
+
static inline int security_quotactl (int cmds, int type, int id,
struct super_block *sb)
{
@@ -1593,6 +1605,11 @@
}
static inline int security_acct (struct file *file)
+{
+ return 0;
+}
+
+static inline int security_sysctl(ctl_table * table, int op)
{
return 0;
}
===== kernel/sysctl.c 1.37 vs edited =====
--- 1.37/kernel/sysctl.c Thu Dec 5 11:06:54 2002
+++ edited/kernel/sysctl.c Fri Jan 17 14:49:15 2003
@@ -33,6 +33,7 @@
#include <linux/highuid.h>
#include <linux/writeback.h>
#include <linux/hugetlb.h>
+#include <linux/security.h>
#include <asm/uaccess.h>
#ifdef CONFIG_ROOT_NFS
@@ -432,6 +433,10 @@
static inline int ctl_perm(ctl_table *table, int op)
{
+ int error;
+ error = security_sysctl(table, op);
+ if (error)
+ return error;
return test_perm(table->mode, op);
}
===== security/dummy.c 1.14 vs edited =====
--- 1.14/security/dummy.c Wed Dec 18 09:11:56 2002
+++ edited/security/dummy.c Fri Jan 17 14:49:15 2003
@@ -75,6 +75,11 @@
return -EPERM;
}
+static int dummy_sysctl (ctl_table * table, int op)
+{
+ return 0;
+}
+
static int dummy_quotactl (int cmds, int type, int id, struct super_block *sb)
{
return 0;
@@ -628,6 +633,7 @@
set_to_dummy_if_null(ops, capable);
set_to_dummy_if_null(ops, quotactl);
set_to_dummy_if_null(ops, quota_on);
+ set_to_dummy_if_null(ops, sysctl);
set_to_dummy_if_null(ops, bprm_alloc_security);
set_to_dummy_if_null(ops, bprm_free_security);
set_to_dummy_if_null(ops, bprm_compute_creds);
--
Stephen Smalley, NSA
sds@epoch.ncsc.mil
next reply other threads:[~2003-01-17 21:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-17 21:54 Stephen D. Smalley [this message]
2003-01-20 0:08 ` Christoph Hellwig
2003-01-20 0:39 ` Russell Coker
2003-01-20 0:43 ` Christoph Hellwig
2003-01-20 1:05 ` Russell Coker
2003-01-21 14:51 Stephen D. 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=200301172154.QAA00757@moss-shockers.ncsc.mil \
--to=sds@epoch.ncsc.mil \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@wirex.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®