All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darrel Goeddel <dgoeddel@TrustedCS.com>
To: Joshua Brindle <jbrindle@tresys.com>
Cc: Karl MacMillan <kmacmillan@mentalrootkit.com>,
	selinux@tycho.nsa.gov, Stephen Smalley <sds@tycho.nsa.gov>
Subject: Re: [PATCH] libsepol users in non-mls policy bugfix
Date: Mon, 30 Oct 2006 12:52:29 -0600	[thread overview]
Message-ID: <454649ED.3000304@trustedcs.com> (raw)
In-Reply-To: <6FE441CD9F0C0C479F2D88F959B01588514786@exchange.columbia.tresys.com>

Joshua Brindle wrote:
>>From: Karl MacMillan [mailto:kmacmillan@mentalrootkit.com] 
>>
>>On Mon, 2006-10-30 at 08:59 -0500, Joshua Brindle wrote:
>>
>>>This patch fixes a bug where adding a user in a non-mls 
>>
>>module would 
>>
>>>cause a segfault at link time.
>>>
>>>
>>>diff -pruN trunk/libsepol/src/link.c 
>>
>>user_mls_fix/libsepol/src/link.c
>>
>>>--- trunk/libsepol/src/link.c	2006-10-28 
>>
>>15:35:26.000000000 -0400
>>
>>>+++ user_mls_fix/libsepol/src/link.c	2006-10-28 
>>
>>15:26:44.000000000 -0400
>>
>>>@@ -994,11 +994,15 @@ static int user_fix_callback(hashtab_key
>>> 		goto cleanup;
>>> 	}
>>> 
>>>-	if (mls_range_convert(&user->range, &new_user->range, mod))
>>>-		goto cleanup;
>>>+	if (mod->policy->mls) {
>>> 
>>>-	if (mls_level_convert(&user->dfltlevel, 
>>
>>&new_user->dfltlevel, mod))
>>
>>>-		goto cleanup;
>>>+		if (mls_range_convert(&user->range, 
>>
>>&new_user->range, mod))
>>
>>>+			goto cleanup;
>>>+
>>>+		if (mls_level_convert(&user->dfltlevel, 
>>
>>&new_user->dfltlevel, mod))
>>
>>>+			goto cleanup;
>>>+
>>>+	}
>>> 
>>> 	return 0;
>>> 
>>>
>>
>>This patch looks ok, but shouldn't we also stop the segfault 
>>in mls_level_convert? The use of assert there looks like it 
>>is catching what should be a runtime error that should cause 
>>an error message rather than bailing.
>>
>>Otherwise:
> 
> 
> Yea, I tried thinking of a more elegant way to do it and couldn't come
> up with anything, any suggestions?
> 
> Clearly those assertions only apply to the MLS case, and we caught a
> plain bug because of them, I think they are not user errors.

How about just putting the mls check in mls_level_convert (as it is in
mls_semantic_level_expand())?

diff -ruNp --exclude=.svn selinux-base/libsepol/src/link.c selinux/libsepol/src/link.c
--- selinux-base/libsepol/src/link.c	2006-10-30 12:48:21.000000000 -0600
+++ selinux/libsepol/src/link.c	2006-10-30 12:45:08.000000000 -0600
@@ -832,6 +832,9 @@ static int mls_level_convert(mls_semanti
 {
 	mls_semantic_cat_t *src_cat, *new_cat;
 
+	if (!mod->policy->mls)
+		return 0;
+
 	assert(mod->map[SYM_LEVELS][src->sens - 1]);
 	dst->sens = mod->map[SYM_LEVELS][src->sens - 1];
 

That will catch all callers of the mls conversion functions in the linker.  The
asserts will then only apply in the MLS case as they should be.

-- 

Darrel

--
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.

  reply	other threads:[~2006-10-30 18:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-30 13:59 [PATCH] libsepol users in non-mls policy bugfix Joshua Brindle
2006-10-30 18:26 ` Karl MacMillan
2006-10-30 18:31   ` Joshua Brindle
2006-10-30 18:52     ` Darrel Goeddel [this message]
2006-10-30 18:56     ` Karl MacMillan
2006-10-30 21:41       ` Joshua Brindle
2006-10-31 18:03         ` Stephen Smalley
2006-10-31 18:40           ` Joshua Brindle

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=454649ED.3000304@trustedcs.com \
    --to=dgoeddel@trustedcs.com \
    --cc=jbrindle@tresys.com \
    --cc=kmacmillan@mentalrootkit.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.