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: Re: [PATCH] Allowing MLS->non-MLS and vice versa upon policy reload
Date: Tue, 02 Feb 2010 23:28:56 +0100	[thread overview]
Message-ID: <1265149736.3605.15.camel@tesla.lan> (raw)
In-Reply-To: <1265048166.12435.206.camel@moss-pluto.epoch.ncsc.mil>

Stephen,

the message quoted below is the message that I was referring to, when I
recalled that the actual behaviour of convert_context() is sub-optimal
(the ssh server case).

On Mon, 2010-02-01 at 13:16 -0500, Stephen Smalley wrote:
> One last comment below:
> 
> On Sun, 2010-01-31 at 23:43 +0100, Guido Trentalancia wrote:
> > diff -pruN security-testing-2.6/security/selinux/ss/services.c security-testing-2.6-new/security/selinux/ss/services.c
> > --- security-testing-2.6/security/selinux/ss/services.c	2010-01-29 02:02:47.742042805 +0100
> > +++ security-testing-2.6-new/security/selinux/ss/services.c	2010-01-31 23:28:26.440336638 +0100
> > @@ -1614,9 +1620,29 @@ static int convert_context(u32 key,
> >  		goto bad;
> >  	c->type = typdatum->value;
> >  
> > -	rc = mls_convert_context(args->oldp, args->newp, c);
> > -	if (rc)
> > -		goto bad;
> > +	/* Convert the MLS/MCS fields or deal with policy type switch */
> > +	if (args->oldp->selinux_mls_enabled
> > +	    && args->newp->selinux_mls_enabled) {
> > +		rc = mls_convert_context(args->oldp, args->newp, c);
> > +		if (rc)
> > +			goto bad;
> > +	} else if (args->oldp->selinux_mls_enabled
> > +		   && !args->newp->selinux_mls_enabled)
> > +	/* Switching between MLS/MCS and non-MLS/non-MCS policy: */
> > +	/* free any storage used by the MLS fields in the        */
> > +	/* context for all existing entries in the sidtab.       */
> > +		mls_context_destroy(args->oldp, c);
> > +	else if (!args->oldp->selinux_mls_enabled
> > +		 && args->newp->selinux_mls_enabled) {
> > +	/* Switching between non-MLS/non-MCS and MLS/MCS policy:  */
> > +	/* ensure that the MLS fields of the context for all      */
> > +	/* existing entries in the sidtab are filled in with a    */
> > +	/* suitable default value, likely taken from one of the   */
> > +	/* initial SIDs.                                          */
> > +		oc = args->newp->ocontexts[OCON_ISID];
> > +		range = &oc->context[0].range;
> > +		mls_range_set(c, range);
> > +	}
> 
> ocontexts[OCON_ISID] is a list of initial SIDs and their contexts.
> Your current code takes the MLS range from whatever happens to be the
> first entry in the list and uses that for all of the contexts.  That
> isn't very well-defined.  At present, the first entry in the list
> happens to be the last initial SID just by virtue of how the list is
> constructed, but nothing else relies on any ordering of that list.
> 
> We could scan the list for a particular initial SID, e.g.
> 	while (oc && oc->sid[0] != SECINITSID_UNLABELED)
> 		oc = oc->next;
> 
> That would at least give us well-defined behavior regardless of the list
> order.  However, it still doesn't really reflect what would happen if
> the system had booted with the MLS/MCS policy in the first place, as
> demonstrated by the sshd behavior.

This is the issue that is bothering me now. We shall tackle it,
preferably in the same patch, because otherwise we would break the
stability of the whole SELinux code.

> Another difference is that initial SID contexts are only loaded upon the
> first policy load (via policydb_load_isids).  I suppose
> convert_context() could in fact just replace c with the contents of
> oc->context[0] if key == oc->sid[0] to update the initial SIDs, although
> care would need to be taken that the number of initial SIDs did not
> change.

We now have a very simple separate patch that calls
policydb_load_isids() at every policy load and not just at the initial
load. I have tested it and it works fine, although it still doesn't
solve the "ssh server issue".

Or is it the "ssh server" that needs to react on that ?

Regards,

Guido


--
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:[~2010-02-02 22:29 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-31 22:43 [PATCH] Allowing MLS->non-MLS and vice versa upon policy reload Guido Trentalancia
2010-02-01 15:28 ` Stephen Smalley
2010-02-01 15:37   ` Stephen Smalley
2010-02-01 18:16 ` Stephen Smalley
2010-02-02 22:28   ` Guido Trentalancia [this message]
2010-02-03 15:48     ` Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2010-02-01 16:36 Guido Trentalancia
2010-02-01 17:41 ` Stephen Smalley
2010-02-01 18:25 Guido Trentalancia
2010-02-01 19:15 ` Stephen Smalley
2010-02-01 19:59 Guido Trentalancia
2010-02-01 20:22 ` Stephen Smalley
2010-02-01 21:49 Guido Trentalancia
2010-02-01 22:09 ` Stephen Smalley
2010-02-01 21:56 Guido Trentalancia
2010-02-01 22:36 Guido Trentalancia
2010-02-04 19:12 ` Eric Paris
2010-02-02 14:22 Guido Trentalancia
2010-02-02 16:44 ` Stephen Smalley
2010-02-02 16:58   ` Guido Trentalancia
2010-02-02 17:34     ` Stephen Smalley
2010-02-02 17:49       ` Guido Trentalancia
2010-02-02 19:01         ` Stephen Smalley
2010-02-02 18:28   ` Guido Trentalancia
2010-02-02 19:03     ` Stephen Smalley
2010-02-02 19:11       ` Stephen Smalley
2010-02-02 16:29 Guido Trentalancia
2010-02-02 16:52 ` Christopher J. PeBenito
2010-02-03 15:40 Guido Trentalancia
2010-02-03 15:53 ` Stephen Smalley
2010-02-03 22:07 ` James Morris
2010-02-04 19:27 Guido Trentalancia
2010-02-04 19:37 ` Eric Paris

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