All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Brindle <method@manicmethod.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov, Daniel J Walsh <dwalsh@redhat.com>
Subject: Re: [patch] libsepol: clarify and reduce neverallow error reporting
Date: Thu, 29 Nov 2007 10:42:18 -0500	[thread overview]
Message-ID: <474EDDDA.9040305@manicmethod.com> (raw)
In-Reply-To: <1196347937.24040.10.camel@moss-spartans.epoch.ncsc.mil>

Stephen Smalley wrote:
> Alter the error reporting for neverallow failures to be clearer, i.e.
> use the word neverallow instead of assertion and don't report a line number
> if we don't have that information, and bail on the first such error rather
> than flooding the user with multiple ones, since any such error is fatal.
>
> Signed-off-by:  Stephen Smalley <sds@tycho.nsa.gov>
>
>   

Acked-By: Joshua Brindle <method@manicmethod.com>


> ---
>
>  libsepol/src/assertion.c |   47 ++++++++++++++++++++++++++++-------------------
>  1 file changed, 28 insertions(+), 19 deletions(-)
>
> Index: trunk/libsepol/src/assertion.c
> ===================================================================
> --- trunk/libsepol/src/assertion.c	(revision 2690)
> +++ trunk/libsepol/src/assertion.c	(working copy)
> @@ -59,11 +59,21 @@
>  	return 0;
>  
>        err:
> -	ERR(handle, "assertion on line %lu violated by allow %s %s:%s {%s };",
> -	    line, p->p_type_val_to_name[stype], p->p_type_val_to_name[ttype],
> -	    p->p_class_val_to_name[curperm->class - 1],
> -	    sepol_av_to_string(p, curperm->class,
> -			       node->datum.data & curperm->data));
> +	if (line) {
> +		ERR(handle, "neverallow on line %lu violated by allow %s %s:%s {%s };",
> +		    line, p->p_type_val_to_name[stype], 
> +		    p->p_type_val_to_name[ttype],
> +		    p->p_class_val_to_name[curperm->class - 1],
> +		    sepol_av_to_string(p, curperm->class,
> +				       node->datum.data & curperm->data));
> +	} else {
> +		ERR(handle, "neverallow violated by allow %s %s:%s {%s };",
> +		    p->p_type_val_to_name[stype], 
> +		    p->p_type_val_to_name[ttype],
> +		    p->p_class_val_to_name[curperm->class - 1],
> +		    sepol_av_to_string(p, curperm->class,
> +				       node->datum.data & curperm->data));
> +	}
>  	return -1;
>  }
>  
> @@ -74,7 +84,7 @@
>  	avtab_t te_avtab, te_cond_avtab;
>  	ebitmap_node_t *snode, *tnode;
>  	unsigned int i, j;
> -	int errors = 0;
> +	int rc;
>  
>  	if (!avrules) {
>  		/* Since assertions are stored in avrules, if it is NULL
> @@ -111,32 +121,31 @@
>  			if (a->flags & RULE_SELF) {
>  				if (check_assertion_helper
>  				    (handle, p, &te_avtab, &te_cond_avtab, i, i,
> -				     a->perms, a->line))
> -					errors++;
> +				     a->perms, a->line)) {
> +					rc = -1;
> +					goto out;
> +				}
>  			}
>  			ebitmap_for_each_bit(ttypes, tnode, j) {
>  				if (!ebitmap_node_get_bit(tnode, j))
>  					continue;
>  				if (check_assertion_helper
>  				    (handle, p, &te_avtab, &te_cond_avtab, i, j,
> -				     a->perms, a->line))
> -					errors++;
> +				     a->perms, a->line)) {
> +					rc = -1;
> +					goto out;
> +				}
>  			}
>  		}
>  	}
>  
> -	if (errors) {
> -		ERR(handle, "%d assertion violations occured", errors);
> -		avtab_destroy(&te_avtab);
> -		avtab_destroy(&te_cond_avtab);
> -		return -1;
> -	}
> -
> +	rc = 0;
> +out:
>  	avtab_destroy(&te_avtab);
>  	avtab_destroy(&te_cond_avtab);
> -	return 0;
> +	return rc;
>  
>        oom:
> -	ERR(handle, "Out of memory - unable to check assertions");
> +	ERR(handle, "Out of memory - unable to check neverallows");
>  	return -1;
>  }
>
>   



--
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:[~2007-11-29 15:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-29 14:52 [patch] libsepol: clarify and reduce neverallow error reporting Stephen Smalley
2007-11-29 15:42 ` Joshua Brindle [this message]
2007-12-03 20:29 ` Brian M. Williams
2007-12-03 20:29   ` Stephen Smalley
2007-12-03 20:37     ` Brian M. Williams

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=474EDDDA.9040305@manicmethod.com \
    --to=method@manicmethod.com \
    --cc=dwalsh@redhat.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.