All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libselinux: Fix file labels for regexes with metachars
@ 2015-07-01 15:31 Jeff Vander Stoep
  2015-07-01 16:26 ` Richard Haines
  2015-07-06 14:59 ` Stephen Smalley
  0 siblings, 2 replies; 3+ messages in thread
From: Jeff Vander Stoep @ 2015-07-01 15:31 UTC (permalink / raw)
  To: selinux

File labels assigned using the lookup_best_match() function do not
assign the best match if its regex contains metacharacters.

For non-exact regex matches, lookup_best_match() finds the closest match
by tracking the length of the matching prefix. Prefix match is tracked via
the prefix_len variable. This was previously calculated and set in
the spec_hasMetaChars() function. Commit 3cb6078 removed the
prefix_len calculation, this commit restores it.

Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
---
 libselinux/src/label_file.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
index 73bcbba..30bc911 100644
--- a/libselinux/src/label_file.h
+++ b/libselinux/src/label_file.h
@@ -148,6 +148,7 @@ static inline void spec_hasMetaChars(struct spec *spec)
 	end = c + len;
 
 	spec->hasMetaChars = 0;
+	spec->prefix_len = len;
 
 	/* Look at each character in the RE specification string for a
 	 * meta character. Return when any meta character reached. */
@@ -164,6 +165,7 @@ static inline void spec_hasMetaChars(struct spec *spec)
 		case '(':
 		case '{':
 			spec->hasMetaChars = 1;
+			spec->prefix_len = c - spec->regex_str;
 			return;
 		case '\\':	/* skip the next character */
 			c++;
-- 
2.4.3.573.g4eafbef

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libselinux: Fix file labels for regexes with metachars
  2015-07-01 15:31 [PATCH] libselinux: Fix file labels for regexes with metachars Jeff Vander Stoep
@ 2015-07-01 16:26 ` Richard Haines
  2015-07-06 14:59 ` Stephen Smalley
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Haines @ 2015-07-01 16:26 UTC (permalink / raw)
  To: Jeff Vander Stoep, selinux@tycho.nsa.gov


> On Wednesday, 1 July 2015, 16:35, Jeff Vander Stoep <jeffv@google.com> wrote:
> > File labels assigned using the lookup_best_match() function do not
> assign the best match if its regex contains metacharacters.
> 
> For non-exact regex matches, lookup_best_match() finds the closest match
> by tracking the length of the matching prefix. Prefix match is tracked via
> the prefix_len variable. This was previously calculated and set in
> the spec_hasMetaChars() function. Commit 3cb6078 removed the
> prefix_len calculation, this commit restores it.
> 

> Signed-off-by: Jeff Vander Stoep <jeffv@google.com>

Ack - Thanks fixes the problem


> ---
> libselinux/src/label_file.h | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
> index 73bcbba..30bc911 100644
> --- a/libselinux/src/label_file.h
> +++ b/libselinux/src/label_file.h
> @@ -148,6 +148,7 @@ static inline void spec_hasMetaChars(struct spec *spec)
>     end = c + len;
> 
>     spec->hasMetaChars = 0;
> +    spec->prefix_len = len;
> 
>     /* Look at each character in the RE specification string for a
>      * meta character. Return when any meta character reached. */
> @@ -164,6 +165,7 @@ static inline void spec_hasMetaChars(struct spec *spec)
>         case '(':
>         case '{':
>             spec->hasMetaChars = 1;
> +            spec->prefix_len = c - spec->regex_str;
>             return;
>         case '\\':    /* skip the next character */
>             c++;
> -- 
> 2.4.3.573.g4eafbef
> 
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to 
> Selinux-request@tycho.nsa.gov.
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libselinux: Fix file labels for regexes with metachars
  2015-07-01 15:31 [PATCH] libselinux: Fix file labels for regexes with metachars Jeff Vander Stoep
  2015-07-01 16:26 ` Richard Haines
@ 2015-07-06 14:59 ` Stephen Smalley
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2015-07-06 14:59 UTC (permalink / raw)
  To: Jeff Vander Stoep, selinux

On 07/01/2015 11:31 AM, Jeff Vander Stoep wrote:
> File labels assigned using the lookup_best_match() function do not
> assign the best match if its regex contains metacharacters.
> 
> For non-exact regex matches, lookup_best_match() finds the closest match
> by tracking the length of the matching prefix. Prefix match is tracked via
> the prefix_len variable. This was previously calculated and set in
> the spec_hasMetaChars() function. Commit 3cb6078 removed the
> prefix_len calculation, this commit restores it.
> 
> Signed-off-by: Jeff Vander Stoep <jeffv@google.com>

Thanks, applied.

> ---
>  libselinux/src/label_file.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
> index 73bcbba..30bc911 100644
> --- a/libselinux/src/label_file.h
> +++ b/libselinux/src/label_file.h
> @@ -148,6 +148,7 @@ static inline void spec_hasMetaChars(struct spec *spec)
>  	end = c + len;
>  
>  	spec->hasMetaChars = 0;
> +	spec->prefix_len = len;
>  
>  	/* Look at each character in the RE specification string for a
>  	 * meta character. Return when any meta character reached. */
> @@ -164,6 +165,7 @@ static inline void spec_hasMetaChars(struct spec *spec)
>  		case '(':
>  		case '{':
>  			spec->hasMetaChars = 1;
> +			spec->prefix_len = c - spec->regex_str;
>  			return;
>  		case '\\':	/* skip the next character */
>  			c++;
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-06 14:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-01 15:31 [PATCH] libselinux: Fix file labels for regexes with metachars Jeff Vander Stoep
2015-07-01 16:26 ` Richard Haines
2015-07-06 14:59 ` Stephen Smalley

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.