All of lore.kernel.org
 help / color / mirror / Atom feed
From: KaiGai Kohei <kaigai@ak.jp.nec.com>
To: method@manicmethod.com
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
	Jacques Thomas <jthomas@cs.purdue.edu>,
	SE Linux <selinux@tycho.nsa.gov>
Subject: [PATCH 2/2] libsepol: remove dead code in check_avtab_hierarchy_callback()
Date: Wed, 20 Jan 2010 13:26:20 +0900	[thread overview]
Message-ID: <4B5685EC.1000500@ak.jp.nec.com> (raw)
In-Reply-To: <4B54339F.8070501@ak.jp.nec.com>

This patch removes dead code in check_avtab_hierarchy_callback().

Due to the historical reason, the type boundary feature is delivered
from hierarchical types in libsepol, it has supported boundary features
both of subject type (domain; in most cases) and target type.

However, we don't have any actual use cases in bounded target types,
and it tended to make conceptual confusion.
So, this patch removes the dead code to apply boundary checks on the
target types in libsepol (when expand-check=1). I makes clear the TYPEBOUNDS
restricts privileges of a certain domain bounded to any other domain.

 Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
--
 libsepol/src/hierarchy.c |   71 ++++++++++++---------------------------------
 1 files changed, 19 insertions(+), 52 deletions(-)

diff --git a/libsepol/src/hierarchy.c b/libsepol/src/hierarchy.c
index e2df5a4..87a9d9c 100644
--- a/libsepol/src/hierarchy.c
+++ b/libsepol/src/hierarchy.c
@@ -159,7 +159,7 @@ static int check_avtab_hierarchy_callback(avtab_key_t * k, avtab_datum_t * d,
 {
 	avtab_key_t key;
 	hierarchy_args_t *a = (hierarchy_args_t *) args;
-	type_datum_t *s, *t1 = NULL, *t2 = NULL;
+	type_datum_t *s, *t;
 	avtab_datum_t av;

 	if (!(k->specified & AVTAB_ALLOWED)) {
@@ -169,62 +169,29 @@ static int check_avtab_hierarchy_callback(avtab_key_t * k, avtab_datum_t * d,

 	/* search for parent first */
 	s = a->p->type_val_to_struct[k->source_type - 1];
-	if (find_parent_type(a, s, &t1) < 0)
+	if (find_parent_type(a, s, &t) < 0)
 		return -1;
-	if (t1) {
-		/*
-		 * search for access allowed between type 1's
-		 * parent and type 2.
-		 */
-		key.source_type = t1->s.value;
-		key.target_type = k->target_type;
-		key.target_class = k->target_class;
-		key.specified = AVTAB_ALLOWED;
-		compute_avtab_datum(a, &key, &av);
-
-		if ((av.data & d->data) == d->data)
-			return 0;
-	}
-
-	/* next we try type 1 and type 2's parent */
-	s = a->p->type_val_to_struct[k->target_type - 1];
-	if (find_parent_type(a, s, &t2) < 0)
-		return -1;
-	if (t2) {
-		/*
-		 * search for access allowed between type 1 and
-		 * type 2's parent.
-		 */
-		key.source_type = k->source_type;
-		key.target_type = t2->s.value;
-		key.target_class = k->target_class;
-		key.specified = AVTAB_ALLOWED;
-		compute_avtab_datum(a, &key, &av);
-
-		if ((av.data & d->data) == d->data)
-			return 0;
-	}

-	if (t1 && t2) {
-		/*
-                 * search for access allowed between type 1's parent
-                 * and type 2's parent.
-                 */
-		key.source_type = t1->s.value;
-		key.target_type = t2->s.value;
-		key.target_class = k->target_class;
-		key.specified = AVTAB_ALLOWED;
-		compute_avtab_datum(a, &key, &av);
-
-		if ((av.data & d->data) == d->data)
-			return 0;
-	}
+	/*
+	 * If the given subject security context does not have any
+	 * parent domain, we don't need to apply sanity checks on
+	 * the type boundary constraint.
+	 */
+	if (!t)
+		return 0;

 	/*
-	 * Neither one of these types have parents and
-	 * therefore the hierarchical constraint does not apply
+	 * Search for access allowed between the parent domain and
+	 * the type. All the permissions with the child domain have
+	 * to be allowed to the parent domain also.
 	 */
-	if (!t1 && !t2)
+	key.source_type = t->s.value;
+	key.target_type = k->target_type;
+	key.target_class = k->target_class;
+	key.specified = AVTAB_ALLOWED;
+	compute_avtab_datum(a, &key, &av);
+
+	if ((av.data & d->data) == d->data)
 		return 0;

 	/*

-- 
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai@ak.jp.nec.com>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  parent reply	other threads:[~2010-01-20  4:26 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-08 19:24 Type boundaries: questions on the semantics / is the enforcement correct ? Jacques Thomas
2009-11-18  2:44 ` KaiGai Kohei
2009-11-19 16:07   ` Jacques Thomas
2009-11-30 18:40     ` Jacques Thomas
2009-12-01  1:02       ` KaiGai Kohei
2009-12-01  3:53         ` Jacques Thomas
2009-12-08 19:46           ` Joshua Brindle
2010-01-15 15:51           ` Stephen Smalley
2010-01-18 10:10             ` KaiGai Kohei
2010-01-20  4:25               ` [PATCH 1/2] selinux: remove dead code in type_attribute_bounds_av() KaiGai Kohei
2010-01-20 13:33                 ` Stephen Smalley
2010-01-20 16:29                   ` contents of /etc/selinux/<type>/contexts/users/* Hasan Rezaul-CHR010
2010-01-20 17:33                     ` Stephen Smalley
2010-01-21  6:00                   ` [PATCH 1/2] selinux: remove dead code in type_attribute_bounds_av() KaiGai Kohei
2010-01-21 14:08                     ` Stephen Smalley
2010-01-24 22:24                     ` James Morris
2010-01-20  4:26               ` KaiGai Kohei [this message]
2010-02-05  5:42                 ` [PATCH 2/2] libsepol: remove dead code in check_avtab_hierarchy_callback() KaiGai Kohei
2010-02-05 14:50                   ` Stephen Smalley
2010-02-09  6:46                     ` KaiGai Kohei
2010-02-16  2:36                       ` KaiGai Kohei
2010-02-16 15:25                         ` Stephen Smalley
2010-02-16 23:49                           ` KaiGai Kohei
2010-02-17 13:51                             ` Stephen Smalley
2010-02-19  7:33                               ` KaiGai Kohei
2010-02-19 15:20                                 ` Stephen Smalley
2010-03-01  2:43                                   ` KaiGai Kohei
2010-03-01 14:34                                     ` Stephen Smalley
2010-03-03  8:09                                       ` KaiGai Kohei
2010-03-04 16:01                                         ` Joshua Brindle
2010-03-04 16:24                                           ` Joshua Brindle
2010-03-05  0:39                                           ` KaiGai Kohei
2010-03-05 14:19                                             ` Joshua Brindle
2010-03-05 14:25                                               ` Stephen Smalley
2010-03-05 14:31                                                 ` Joshua Brindle
2010-03-08  6:56                                                   ` KaiGai Kohei
2010-03-08 15:27                                                     ` Joshua Brindle
2010-02-19 17:31                             ` Stephen Smalley
2010-02-21 22:09                             ` James Morris

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=4B5685EC.1000500@ak.jp.nec.com \
    --to=kaigai@ak.jp.nec.com \
    --cc=jthomas@cs.purdue.edu \
    --cc=method@manicmethod.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.