mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Serge Hallyn <serue@us.ibm.com>
To: Chris Wright <chrisw@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] [PATCH] [6/6] LSM Stacking: temporary setprocattr hack
Date: Thu, 04 Nov 2004 17:12:51 -0600	[thread overview]
Message-ID: <1099609971.2096.26.camel@serge.austin.ibm.com> (raw)
In-Reply-To: <1099609471.2096.10.camel@serge.austin.ibm.com>

Stacker assumes that data written to /proc/<pid>/attr/* is of the
form:

module_name: data

Until the SELinux tools are rewritten to use this form, or it is decided
other LSMs should use a different way of communicating with userspace,
this patch will assume that data not in this form is intended for SELinux.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>

Index: linux-2.6.10-rc1-bk14/security/stacker.c
===================================================================
--- linux-2.6.10-rc1-bk14.orig/security/stacker.c	2004-11-04
12:31:02.636390608 -0600
+++ linux-2.6.10-rc1-bk14/security/stacker.c	2004-11-04
12:31:12.248929280 -0600
@@ -91,6 +91,8 @@
    pointed to by stacked_modules. It's initially NULL (an empty list).
*/
 struct module_entry *stacked_modules;
 
+static struct module_entry *selinux_module;
+static int selinux_is_loaded;
 
 /* penultimate_stacked_module points to the next-to-last
  * entry in the stacked list if there are 2+ entries, else it's NULL;
@@ -1007,12 +1009,20 @@
 
 	s = value;
 	e = strnchr(s, size, ':');
+	if (!e && selinux_is_loaded) {
+		m = selinux_module;
+		goto cont;
+	}
 	if (!e) {
 		printk(KERN_INFO "%s: couln't find module name end\n",
 			__FUNCTION__);
 		return -EINVAL;
 	}
 	m = find_lsm_module_by_name(s,e);
+	if (!m && selinux_is_loaded) {
+		m = selinux_module;
+		goto cont;
+	}
 	if (!m) {
 		strncpy(modname, s, 50);
 		modname[49] = '\0';
@@ -1021,6 +1031,7 @@
 		return -EINVAL;
 	}
 	s = e+1;
+cont:
 	while ((void *)s < value+size && *s == ' ')
 		s++;
 	if (s == value+size) {
@@ -1028,9 +1039,7 @@
 		return -EINVAL;
 	}
 	len = size - (int)((void *)s - value);
-	printk(KERN_INFO "%s: sending to module\n", __FUNCTION__);
 	ret = m->module_operations.setprocattr(p,name,s,len);
-	printk(KERN_INFO "%s: ret was %d, returning %d\n", __FUNCTION__, ret,
ret+(size-len));
 	if (ret < 0)
 		return ret;
 	return ret + (size-len);
@@ -1092,6 +1101,10 @@
 	new_module_entry->namelen = namelen;
 
 	add_module_entry(new_module_entry);
+	if (strcmp(name, "selinux") == 0) {
+		selinux_is_loaded = 1;
+		selinux_module = new_module_entry;
+	}
 
 	/* One more write barrier; this one is to _ensure_ that the
 	 * inactive list is valid before releasing the locking. */
@@ -1139,6 +1152,10 @@
 			penultimate_stacked_module = bb;
 	}
 	num_stacked_modules--;
+	if (strcmp(m->module_name, "selinux") == 0) {
+		selinux_is_loaded = 0;
+		selinux_module = NULL;
+	}
 	kfree(m->module_name);
 	kfree(m);
 out:
@@ -1567,6 +1584,9 @@
 	sysfsfiles_registered = 0;
 	num_stacked_modules = 0;
 
+	selinux_is_loaded = 0;
+	selinux_module = NULL;
+
 	INIT_STACKER_LOCKING;
 
 	if (register_security (&stacker_ops)) {



  parent reply	other threads:[~2004-11-04 22:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-04 23:04 [RFC] [PATCH] [0/6] LSM Stacking Serge Hallyn
2004-11-04 22:52 ` Chris Wright
2004-11-05  1:01   ` Serge E. Hallyn
2004-11-05  1:05     ` Chris Wright
2004-11-05  2:16       ` James Morris
2004-11-04 23:06 ` [RFC] [PATCH] [1/6] LSM Stacking: Replace LSM void* with arrays Serge Hallyn
2004-11-04 22:34   ` Chris Wright
2004-11-04 23:08 ` [RFC] [PATCH] [2/6] LSM Stacking: Add stacker LSM Serge Hallyn
2004-11-04 22:42   ` Chris Wright
2004-11-10 17:43   ` Jonathan Corbet
2004-11-10 19:32     ` Serge E. Hallyn
2004-11-04 23:08 ` [RFC] [PATCH] [3/6] LSM Stacking: capability LSM stacking support Serge Hallyn
2004-11-04 23:09 ` [RFC] [PATCH] [4/6] LSM Stacking: seclvl " Serge Hallyn
2004-11-04 23:11 ` [RFC] [PATCH] [5/6] LSM Stacking: SELinux " Serge Hallyn
2004-11-04 22:45   ` Chris Wright
2004-11-04 23:12 ` Serge Hallyn [this message]
2004-11-04 22:48   ` [RFC] [PATCH] [6/6] LSM Stacking: temporary setprocattr hack Chris Wright
2004-11-05  0:52     ` Serge E. Hallyn
2004-11-05  0:56       ` Chris Wright
2004-11-04 23:14 ` [RFC] [PATCH] [1/3] LSM Stacking: stackable bsdjail (tasklookup) Serge Hallyn
2004-11-04 23:15 ` [RFC] [PATCH] [2/3] LSM Stacking: stackable bsdjail (bsdjail lsm) Serge Hallyn
2004-11-04 23:16 ` [RFC] [PATCH] [3/3] LSM Stacking: stackable bsdjail (Documentation) Serge Hallyn
2004-11-04 23:51 ` [RFC] [PATCH] [0/6] LSM Stacking James Morris
2004-11-05  7:23 ` Valdis.Kletnieks
2004-11-05 16:32   ` Serge E. Hallyn
2004-11-05 16:51   ` 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=1099609971.2096.26.camel@serge.austin.ibm.com \
    --to=serue@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=chrisw@osdl.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®