All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darrel Goeddel <dgoeddel@TrustedCS.com>
To: Joshua Brindle <jbrindle@tresys.com>
Cc: SELinux List <SELinux@tycho.nsa.gov>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Eric Paris <eparis@redhat.com>
Subject: Re: [PATCH 2/2] userland support for new range_transition statements
Date: Wed, 02 Aug 2006 11:38:46 -0500	[thread overview]
Message-ID: <44D0D516.5010906@trustedcs.com> (raw)
In-Reply-To: <1154438074.23513.30.camel@twoface.columbia.tresys.com>

Joshua Brindle wrote:
> On Fri, 2006-07-28 at 11:13 -0400, Darrel Goeddel wrote:
> 
>>Index: libsepol/include/sepol/policydb/policydb.h
>>===================================================================
>>--- libsepol/include/sepol/policydb/policydb.h  (revision 38)
>>+++ libsepol/include/sepol/policydb/policydb.h  (working copy)
> 
> 
>>+typedef struct range_trans_rule {
>>+       type_set_t stypes;
>>+       type_set_t ttypes;
>>+       class_perm_node_t *classes;     /* only class is used */
>>+       mls_range_t trange;
>>+       struct range_trans_rule *next;
>>+} range_trans_rule_t;
>>+
> 
> 
> Are we sure that mls_range_t is semantic enough to store the rule, even
> in a module situation where all the symbols are not present?

Hmmm...  I assume that you have MLS requirements in mind when you say that,
especially the '.' notation.  The problem is that if we specify "s4:c0.c12" as
the range, how do we know what will be between c0 and c12 (they are arbitrary
names).  Are you suggesting possibly storing the string and figuring the whole
thing out at expand time?

We could also make sensitivity and category names non-arbitrary and force the 
naming convention of s# and c# ;)  Translations take care of human-readable for
us now...

>>+static int expand_range_trans(expand_state_t *state,
>>range_trans_rule_t *rules)
>>+{
>>+       unsigned int i, j;
>>+       range_trans_t *rt, *lrt, *cur_rt;
>>+       range_trans_rule_t *rule;
>>+       class_perm_node_t *cp;
>>+
>>+       ebitmap_t stypes, ttypes;
>>+       ebitmap_node_t *snode, *tnode;
>>+
>>+       /* start appending at the end of the current list */
>>+       for (lrt = state->out->range_tr; lrt && lrt->next; lrt =
>>lrt->next)
>>+               ;
> 
> 
> I know the current code is like this, it was probably done that way to
> match the pre-module compiler behavior but we could probably change
> these to prepend, for simpler code.

I'll look at that.

>>+                                       rt = (range_trans_t
>>*)malloc(sizeof(range_trans_t));
>>+                                       if (!rt) {
>>+                                               ERR(state->handle,
>>"Out of memory!");
>>+                                               return -1;
>>+                                       }
>>+                                       memset(rt, 0,
>>sizeof(range_trans_t));
> 
> 
> It is my preference to have initializers for structs but even if not the
> current trend in this library is to turn malloc/memset into calloc.
> (Though I'd really prefer an initializer just so that these sites don't
> have to be audited when the struct changes)

I'll check on this as well - I'll at least change to calloc.

>>+               new_range->target_class = range->target_class;
>>+               if (mls_level_clone(&new_range->target_range.level[0],
>>+                                   &range->target_range.level[0]) ||
>>+                   mls_level_clone(&new_range->target_range.level[1],
>>+                                   &range->target_range.level[1])) {
> 
> 
> can we break these into separate calls? It is easier to read IMO

Yep.

>>        items = put_entry(buf, sizeof(uint32_t), 1, fp);
>>        if (items != 1)
>>                return -1;
>>        for (rt = p->range_tr; rt; rt = rt->next) {
>>-               buf[0] = cpu_to_le32(rt->dom);
>>-               buf[1] = cpu_to_le32(rt->type);
>>+               if (!new_rangetr && rt->target_class !=
>>SECCLASS_PROCESS)
>>+                       continue;
> 
> 
> I think this was mentioned in another email but a WARN() should probably
> be put here

Will do.

>>+       rule = malloc(sizeof(struct range_trans_rule));
>>+       if (!rule) {
>>+               yyerror("out of memory");
>>+               return -1;
>>+       }
>>+       memset(rule, 0, sizeof(struct range_trans_rule));
> 
> 
> init?

Sounds like a plan.

> In addition to the other comments this looks pretty good. I hope that
> we'll be able to use this format change to allow range_trans in modules.

Cool.  I hope to have a revision of the patch that includes your all of the
feedback received so far (except the mls_range_t in the range_trans_rule_t - I
think there will be more discussion there) by tomorrow afternoon.


-- 

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-08-02 16:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-28 15:13 [PATCH 2/2] userland support for new range_transition statements Darrel Goeddel
2006-07-31 16:40 ` Stephen Smalley
2006-07-31 18:25   ` Darrel Goeddel
2006-07-31 18:29 ` Karl MacMillan
2006-07-31 18:54   ` Darrel Goeddel
2006-07-31 20:52     ` Stephen Smalley
2006-08-01 13:14 ` Joshua Brindle
2006-08-02 16:38   ` Darrel Goeddel [this message]
2006-08-02 19:51     ` Karl MacMillan
2006-08-02 21:59       ` Darrel Goeddel
2006-08-03 12:01         ` Joshua Brindle
2006-08-03 15:55     ` Joshua Brindle
2006-08-04 16:13       ` Darrel Goeddel
2006-08-07 13:18         ` Joshua Brindle
2006-08-08 14:48           ` Darrel Goeddel
2006-08-08 22:45             ` Joshua Brindle
2006-08-09 15:00               ` Darrel Goeddel
2006-08-04 17:10 ` [PATCH 2/2 take 2] " Darrel Goeddel
2006-08-08 22:25   ` Joshua Brindle
2006-08-09 13:09     ` Karl MacMillan
2006-08-09 13:31       ` Joshua Brindle
2006-08-09 15:06         ` Darrel Goeddel
2006-08-09 15:13           ` Karl MacMillan
2006-08-09 15:39             ` [PATCH 2/2 take 2] userland support for new range_transitionstatements Joshua Brindle
2006-08-09 14:29     ` [PATCH 2/2 take 2] userland support for new range_transition statements Darrel Goeddel

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=44D0D516.5010906@trustedcs.com \
    --to=dgoeddel@trustedcs.com \
    --cc=SELinux@tycho.nsa.gov \
    --cc=eparis@redhat.com \
    --cc=jbrindle@tresys.com \
    --cc=sds@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.