All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: James Carter <jwcart2@tycho.nsa.gov>, selinux@tycho.nsa.gov
Subject: Re: [PATCH 01/10 v2] libsepol: Add new ebitmap function named ebitmap_match_any()
Date: Thu, 18 Jun 2015 09:23:33 -0400	[thread overview]
Message-ID: <5582C655.9000904@tycho.nsa.gov> (raw)
In-Reply-To: <1434571134-31452-2-git-send-email-jwcart2@tycho.nsa.gov>

On 06/17/2015 03:58 PM, James Carter wrote:
> This function returns true if there is a common bit that is set
> in both bitmaps.
> 
> Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>

Acked-by:  Stephen Smalley <sds@tycho.nsa.gov>

> ---
>  libsepol/include/sepol/policydb/ebitmap.h |  1 +
>  libsepol/src/ebitmap.c                    | 22 ++++++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/libsepol/include/sepol/policydb/ebitmap.h b/libsepol/include/sepol/policydb/ebitmap.h
> index 801438c..7b3508d 100644
> --- a/libsepol/include/sepol/policydb/ebitmap.h
> +++ b/libsepol/include/sepol/policydb/ebitmap.h
> @@ -86,6 +86,7 @@ extern unsigned int ebitmap_cardinality(ebitmap_t *e1);
>  extern int ebitmap_hamming_distance(ebitmap_t * e1, ebitmap_t * e2);
>  extern int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src);
>  extern int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2);
> +extern int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2);
>  extern int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit);
>  extern int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value);
>  extern void ebitmap_destroy(ebitmap_t * e);
> diff --git a/libsepol/src/ebitmap.c b/libsepol/src/ebitmap.c
> index be6b591..58f2fc4 100644
> --- a/libsepol/src/ebitmap.c
> +++ b/libsepol/src/ebitmap.c
> @@ -224,6 +224,28 @@ int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
>  	return 1;
>  }
>  
> +int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
> +{
> +	ebitmap_node_t *n1 = e1->node;
> +	ebitmap_node_t *n2 = e2->node;
> +
> +	while (n1 && n2) {
> +		if (n1->startbit < n2->startbit) {
> +			n1 = n1->next;
> +		} else if (n2->startbit < n1->startbit) {
> +			n2 = n2->next;
> +		} else {
> +			if (n1->map & n2->map) {
> +				return 1;
> +			}
> +			n1 = n1->next;
> +			n2 = n2->next;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit)
>  {
>  	ebitmap_node_t *n;
> 

  reply	other threads:[~2015-06-18 13:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 19:58 [PATCH 00/10 v2] Improve libsepol and CIL neverallow and bounds checking James Carter
2015-06-17 19:58 ` [PATCH 01/10 v2] libsepol: Add new ebitmap function named ebitmap_match_any() James Carter
2015-06-18 13:23   ` Stephen Smalley [this message]
2015-06-17 19:58 ` [PATCH 02/10 v2] libsepol: Treat types like an attribute in the attr_type_map James Carter
2015-06-18 13:41   ` Stephen Smalley
2015-06-18 13:52     ` Stephen Smalley
2015-06-18 20:16     ` James Carter
2015-06-18 20:21       ` Stephen Smalley
2015-06-18 20:23         ` Stephen Smalley
2015-06-17 19:58 ` [PATCH 03/10 v2] libsepol: Refactored neverallow checking James Carter
2015-06-17 19:58 ` [PATCH 04/10 v2] libsepol: Refactored bounds (hierarchy) checking code James Carter
2015-06-18 13:56   ` Stephen Smalley
2015-06-18 20:26     ` James Carter
2015-06-18 20:29       ` Stephen Smalley
2015-06-18 20:35         ` James Carter
2015-06-17 19:58 ` [PATCH 05/10 v2] libsepol/cil: Add function to search the CIL AST for an AV rule James Carter
2015-06-17 19:58 ` [PATCH 06/10 v2] libsepol/cil: Refactored CIL neverallow checking and reporting James Carter
2015-06-17 19:58 ` [PATCH 07/10 v2] libsepol/cil: Track number of classes and number of types and attributes James Carter
2015-06-17 19:58 ` [PATCH 08/10 v2] libsepol/cil: Add CIL bounds checking and reporting James Carter
2015-06-17 19:58 ` [PATCH 09/10 v2] secilc: Add a CIL policy file to test neverallow checking James Carter
2015-06-17 19:58 ` [PATCH 10/10 v2] 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=5582C655.9000904@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=jwcart2@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.