All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Extend checkpolicy pathname matching.
@ 2016-07-14 15:47 Stephen Smalley
  2016-07-18  9:29 ` Inamdar Sharif
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Smalley @ 2016-07-14 15:47 UTC (permalink / raw)
  To: selinux; +Cc: isharif, seandroid-list, Stephen Smalley

checkpolicy currently imposes arbitrary limits on pathnames used
in genfscon and other statements.  This prevents specifying certain
paths in /proc such as those containing comma (,) characters.

Generalize the PATH, QPATH, and FILENAME patterns to support most
legal pathnames.

For simplicity, we do not support pathnames containing newlines or
quotes.

Reported-by: Inamdar Sharif <isharif@nvidia.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
---
 checkpolicy/policy_scan.l | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/checkpolicy/policy_scan.l b/checkpolicy/policy_scan.l
index 22da338..2f7f221 100644
--- a/checkpolicy/policy_scan.l
+++ b/checkpolicy/policy_scan.l
@@ -249,9 +249,9 @@ high |
 HIGH				{ return(HIGH); }
 low |
 LOW				{ return(LOW); }
-"/"({alnum}|[_\.\-/])*	        { return(PATH); }
-\""/"[ !#-~]*\" 		{ return(QPATH); }
-\"({alnum}|[_\.\-\+\~\: ])+\"	{ return(FILENAME); }
+"/"[^ \n\r\t\f]*	        { return(PATH); }
+\""/"[^\"\n]*\" 		{ return(QPATH); }
+\"[^"/"\"\n]+\"	{ return(FILENAME); }
 {letter}({alnum}|[_\-])*([\.]?({alnum}|[_\-]))*	{ return(IDENTIFIER); }
 {digit}+|0x{hexval}+            { return(NUMBER); }
 {alnum}*{letter}{alnum}*        { return(FILESYSTEM); }
-- 
2.5.5

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

* RE: [PATCH] Extend checkpolicy pathname matching.
  2016-07-14 15:47 [PATCH] Extend checkpolicy pathname matching Stephen Smalley
@ 2016-07-18  9:29 ` Inamdar Sharif
  0 siblings, 0 replies; 2+ messages in thread
From: Inamdar Sharif @ 2016-07-18  9:29 UTC (permalink / raw)
  To: Stephen Smalley, selinux; +Cc: seandroid-list

Thanks Stephen. That works.

-----Original Message-----
From: Stephen Smalley [mailto:sds@tycho.nsa.gov] 
Sent: Thursday, July 14, 2016 9:18 PM
To: selinux@tycho.nsa.gov
Cc: Inamdar Sharif; seandroid-list@tycho.nsa.gov; Stephen Smalley
Subject: [PATCH] Extend checkpolicy pathname matching.

checkpolicy currently imposes arbitrary limits on pathnames used in genfscon and other statements.  This prevents specifying certain paths in /proc such as those containing comma (,) characters.

Generalize the PATH, QPATH, and FILENAME patterns to support most legal pathnames.

For simplicity, we do not support pathnames containing newlines or quotes.

Reported-by: Inamdar Sharif <isharif@nvidia.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
---
 checkpolicy/policy_scan.l | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/checkpolicy/policy_scan.l b/checkpolicy/policy_scan.l index 22da338..2f7f221 100644
--- a/checkpolicy/policy_scan.l
+++ b/checkpolicy/policy_scan.l
@@ -249,9 +249,9 @@ high |
 HIGH				{ return(HIGH); }
 low |
 LOW				{ return(LOW); }
-"/"({alnum}|[_\.\-/])*	        { return(PATH); }
-\""/"[ !#-~]*\" 		{ return(QPATH); }
-\"({alnum}|[_\.\-\+\~\: ])+\"	{ return(FILENAME); }
+"/"[^ \n\r\t\f]*	        { return(PATH); }
+\""/"[^\"\n]*\" 		{ return(QPATH); }
+\"[^"/"\"\n]+\"	{ return(FILENAME); }
 {letter}({alnum}|[_\-])*([\.]?({alnum}|[_\-]))*	{ return(IDENTIFIER); }
 {digit}+|0x{hexval}+            { return(NUMBER); }
 {alnum}*{letter}{alnum}*        { return(FILESYSTEM); }
--
2.5.5

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

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

end of thread, other threads:[~2016-07-18  9:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-14 15:47 [PATCH] Extend checkpolicy pathname matching Stephen Smalley
2016-07-18  9:29 ` Inamdar Sharif

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.