All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guido Trentalancia <guido@trentalancia.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov
Subject: [PATCH] Load the initial SIDs upon every policy load
Date: Tue, 02 Feb 2010 23:36:21 +0100	[thread overview]
Message-ID: <1265150181.3605.23.camel@tesla.lan> (raw)

[-- Attachment #1: Type: text/plain, Size: 1865 bytes --]

Stephen,

attached please find the tiny patch for always loading the initial SIDs.
Should I say "for review" ? It relies on SECINITSID_NUM which at the
moment is statically defined in flask.h (and represents the maximum
initial SID).

Author: Guido Trentalancia <guido@trentalancia.com>
Date:   Mon Feb 02 22:11:05 2010 +0100

    Always load the initial SIDs, even in the case of a policy
    reload and not just at the initial policy load. This comes
    particularly handy after the introduction of a recent
    patch for enabling runtime switching between different
    policy types, although this patch is in theory independent
    from that feature.

    Signed-off-by: Guido Trentalancia <guido@trentalancia.com>

---

 security/selinux/ss/services.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

--- security-testing-2.6/security/selinux/ss/services.c	2010-01-29 02:02:47.742042805 +0100
+++ security-testing-2.6-isids/security/selinux/ss/services.c	2010-02-02 22:09:47.809993219 +0100
@@ -1506,7 +1506,10 @@ static int clone_sid(u32 sid,
 {
 	struct sidtab *s = arg;
 
-	return sidtab_insert(s, sid, context);
+	if (sid > SECINITSID_NUM)
+		return sidtab_insert(s, sid, context);
+	else
+		return 0;
 }
 
 static inline int convert_context_handle_invalid_context(struct context *context)
@@ -1552,7 +1555,10 @@ static int convert_context(u32 key,
 	struct user_datum *usrdatum;
 	char *s;
 	u32 len;
-	int rc;
+	int rc = 0;
+
+	if (key <= SECINITSID_NUM)
+		goto out;
 
 	args = p;
 
@@ -1712,9 +1718,9 @@ int security_load_policy(void *data, siz
 	if (policydb_read(&newpolicydb, fp))
 		return -EINVAL;
 
-	if (sidtab_init(&newsidtab)) {
+	if (policydb_load_isids(&newpolicydb, &newsidtab)) {
 		policydb_destroy(&newpolicydb);
-		return -ENOMEM;
+		return -EINVAL;
 	}
 
 	if (selinux_set_mapping(&newpolicydb, secclass_map,


[-- Attachment #2: always_load_initial_sids.patch --]
[-- Type: text/x-patch, Size: 1629 bytes --]

Author: Guido Trentalancia <guido@trentalancia.com>
Date:   Mon Feb 02 22:11:05 2010 +0100

    Always load the initial SIDs, even in the case of a policy
    reload and not just at the initial policy load. This comes
    particularly handy after the introduction of a recent
    patch for enabling runtime switching between different
    policy types, although this patch is in theory independent
    from that feature.

    Signed-off-by: Guido Trentalancia <guido@trentalancia.com>

---

 security/selinux/ss/services.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

--- security-testing-2.6/security/selinux/ss/services.c	2010-01-29 02:02:47.742042805 +0100
+++ security-testing-2.6-isids/security/selinux/ss/services.c	2010-02-02 22:09:47.809993219 +0100
@@ -1506,7 +1506,10 @@ static int clone_sid(u32 sid,
 {
 	struct sidtab *s = arg;
 
-	return sidtab_insert(s, sid, context);
+	if (sid > SECINITSID_NUM)
+		return sidtab_insert(s, sid, context);
+	else
+		return 0;
 }
 
 static inline int convert_context_handle_invalid_context(struct context *context)
@@ -1552,7 +1555,10 @@ static int convert_context(u32 key,
 	struct user_datum *usrdatum;
 	char *s;
 	u32 len;
-	int rc;
+	int rc = 0;
+
+	if (key <= SECINITSID_NUM)
+		goto out;
 
 	args = p;
 
@@ -1712,9 +1718,9 @@ int security_load_policy(void *data, siz
 	if (policydb_read(&newpolicydb, fp))
 		return -EINVAL;
 
-	if (sidtab_init(&newsidtab)) {
+	if (policydb_load_isids(&newpolicydb, &newsidtab)) {
 		policydb_destroy(&newpolicydb);
-		return -ENOMEM;
+		return -EINVAL;
 	}
 
 	if (selinux_set_mapping(&newpolicydb, secclass_map,

             reply	other threads:[~2010-02-02 22:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-02 22:36 Guido Trentalancia [this message]
2010-02-03 15:58 ` [PATCH] Load the initial SIDs upon every policy load Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2010-02-03 17:59 Guido Trentalancia
2010-02-03 18:14 ` 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=1265150181.3605.23.camel@tesla.lan \
    --to=guido@trentalancia.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /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 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.