All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christopher J. PeBenito" <cpebenito@tresys.com>
To: Stephen Smalley <sds@tycho.nsa.gov>,
	James Carter <jwcart2@tycho.nsa.gov>, <selinux@tycho.nsa.gov>
Subject: Re: [PATCH 03/10] libsepol: Refactored neverallow checking.
Date: Fri, 12 Jun 2015 08:55:04 -0400	[thread overview]
Message-ID: <557AD6A8.6030601@tresys.com> (raw)
In-Reply-To: <5579EA96.5020108@tycho.nsa.gov>

On 6/11/2015 4:07 PM, Stephen Smalley wrote:
> On 06/11/2015 02:26 PM, James Carter wrote:
>> Instead of creating an expanded avtab, generating all of the avtab
>> keys corresponding to a neverallow rule and searching for a match,
>> walk the nodes in the avtab and use the attr_type_map and ebitmap
>> functions to find matching rules.
>>
>> Memory usage is reduced from 370M to 125M and time is reduced from
>> 14 sec to 2 sec. (Bounds checking commented out in both cases.)
>>
>> Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
>> ---
>>  libsepol/include/sepol/policydb/policydb.h |   2 +-
>>  libsepol/src/assertion.c                   | 225 ++++++++++++++++++-----------
>>  2 files changed, 145 insertions(+), 82 deletions(-)
>>
>> diff --git a/libsepol/include/sepol/policydb/policydb.h b/libsepol/include/sepol/policydb/policydb.h
>> index 1d8310c..b3cf9db 100644
>> --- a/libsepol/include/sepol/policydb/policydb.h
>> +++ b/libsepol/include/sepol/policydb/policydb.h
>> @@ -652,7 +652,7 @@ extern void level_datum_init(level_datum_t * x);
>>  extern void level_datum_destroy(level_datum_t * x);
>>  extern void cat_datum_init(cat_datum_t * x);
>>  extern void cat_datum_destroy(cat_datum_t * x);
>> -
>> +extern int check_assertion(policydb_t *p, avrule_t *avrule);
>>  extern int check_assertions(sepol_handle_t * handle,
>>  			    policydb_t * p, avrule_t * avrules);
>>  
>> diff --git a/libsepol/src/assertion.c b/libsepol/src/assertion.c
>> index c335968..35698df 100644
>> --- a/libsepol/src/assertion.c
>> +++ b/libsepol/src/assertion.c
>> @@ -27,11 +27,16 @@
>>  
>>  #include "debug.h"
>>  
>> -static void report_failure(sepol_handle_t *handle, policydb_t *p,
>> -			   const avrule_t * avrule,
>> +struct avtab_match_args {
>> +	sepol_handle_t *handle;
>> +	policydb_t *p;
>> +	avrule_t *avrule;
>> +	unsigned long errors;
>> +};
>> +
>> +static void report_failure(sepol_handle_t *handle, policydb_t *p, const avrule_t *avrule,
>>  			   unsigned int stype, unsigned int ttype,
>> -			   const class_perm_node_t *curperm,
>> -			   const avtab_ptr_t node)
>> +			   const class_perm_node_t *curperm, uint32_t perms)
>>  {
>>  	if (avrule->source_filename) {
>>  		ERR(handle, "neverallow on line %lu of %s (or line %lu of policy.conf) violated by allow %s %s:%s {%s };",
>> @@ -39,69 +44,164 @@ static void report_failure(sepol_handle_t *handle, policydb_t *p,
>>  		    p->p_type_val_to_name[stype],
>>  		    p->p_type_val_to_name[ttype],
>>  		    p->p_class_val_to_name[curperm->tclass - 1],
>> -		    sepol_av_to_string(p, curperm->tclass,
>> -				       node->datum.data & curperm->data));
>> +		    sepol_av_to_string(p, curperm->tclass, perms));
> 
> So you're reporting the entire list of permissions from the allow rule,
> not just the offending ones?  I guess I could go either way; the old
> approach was more indicative of what the problem was, while the new is
> closer to what they might find in source (albeit after macro expansion).

My preference would be to only list the offending permissions.

-- 
Chris PeBenito
Tresys Technology, LLC
www.tresys.com | oss.tresys.com

  reply	other threads:[~2015-06-12 12:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 18:26 [PATCH 00/10] Improve libsepol and CIL neverallow and bounds checking James Carter
2015-06-11 18:26 ` [PATCH 01/10] libsepol: Add new ebitmap function named ebitmap_match_any() James Carter
2015-06-11 18:26 ` [PATCH 02/10] libsepol: Treat types like an attribute in the attr_type_map James Carter
2015-06-11 20:03   ` Stephen Smalley
2015-06-12 12:14     ` James Carter
2015-06-12 12:22       ` Stephen Smalley
2015-06-12 13:02         ` James Carter
2015-06-11 18:26 ` [PATCH 03/10] libsepol: Refactored neverallow checking James Carter
2015-06-11 20:07   ` Stephen Smalley
2015-06-12 12:55     ` Christopher J. PeBenito [this message]
2015-06-12 12:59     ` James Carter
2015-06-12 13:05       ` James Carter
2015-06-11 18:26 ` [PATCH 04/10] libsepol: Refactored bounds (hierarchy) checking code James Carter
2015-06-11 18:26 ` [PATCH 05/10] libsepol/cil: Add function to search the CIL AST for an AV rule James Carter
2015-06-12 18:27   ` Steve Lawrence
2015-06-15 13:59     ` James Carter
2015-06-11 18:26 ` [PATCH 06/10] libsepol/cil: Refactored CIL neverallow checking and reporting James Carter
2015-06-11 18:26 ` [PATCH 07/10] libsepol/cil: Track number of classes and number of types and attributes James Carter
2015-06-11 18:26 ` [PATCH 08/10] libsepol/cil: Add CIL bounds checking and reporting James Carter
2015-06-11 18:26 ` [PATCH 09/10] secilc: Add a CIL policy file to test neverallow checking James Carter
2015-06-11 18:26 ` [PATCH 10/10] secilc: Add a CIL policy file to test bounds checking James Carter

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=557AD6A8.6030601@tresys.com \
    --to=cpebenito@tresys.com \
    --cc=jwcart2@tycho.nsa.gov \
    --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.