checkpolicy: Fix precedence between number and filesystem tokens.
PATCH 1/1 checkpolicy: Fix precedence between number and filesystem tokens.
When the FILESYSTEM token was added to support filesystem names that start with a digit (e.g. 9p), it was given higher precedence than NUMBER and therefore all values specified in hex (with 0x prefix) in policy will incorrectly match FILESYSTEM and yield a syntax error. This breaks use of iomem ranges in Xen policy and will break ioctl command ranges in a future SELinux policy version. Switch the precedence. This does mean that you cannot currently have a filesystem with a name that happens to be 0x followed by a hexval but hopefully that isn't an issue.
--- checkpolicy/policy_scan.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
checkpolicy/policy_scan.l +1 -1
@@ -242,8 +242,8 @@ LOW { return(LOW); } "/"({alnum}|[_\.\-/])* { return(PATH); } \"({alnum}|[_\.\-\+\~\: ])+\" { return(FILENAME); } {letter}({alnum}|[_\-])*([\.]?({alnum}|[_\-]))* { return(IDENTIFIER); } -{alnum}*{letter}{alnum}* { return(FILESYSTEM); } {digit}+|0x{hexval}+ { return(NUMBER); } +{alnum}*{letter}{alnum}* { return(FILESYSTEM); } {digit}{1,3}(\.{digit}{1,3}){3} { return(IPV4_ADDR); } {hexval}{0,4}":"{hexval}{0,4}":"({hexval}|[:.])* { return(IPV6_ADDR); } {digit}+(\.({alnum}|[_.])*)? { return(VERSION_IDENTIFIER); }
Signature · 1 line
1.9.3
Quoted 40 lines · Stephen Smalley
When the FILESYSTEM token was added to support filesystem names that start with a digit (e.g. 9p), it was given higher precedence than NUMBER and therefore all values specified in hex (with 0x prefix) in policy will incorrectly match FILESYSTEM and yield a syntax error. This breaks use of iomem ranges in Xen policy and will break ioctl command ranges in a future SELinux policy version. Switch the precedence. This does mean that you cannot currently have a filesystem with a name that happens to be 0x followed by a hexval but hopefully that isn't an issue.
Signed-off-by Stephen Smalley <[email protected]>--- checkpolicy/policy_scan.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)checkpolicy/policy_scan.l +1
-1@@ -242,8 +242,8 @@ LOW { return(LOW); } "/"({alnum}|[_\.\-/])* { return(PATH); } \"({alnum}|[_\.\-\+\~\: ])+\" { return(FILENAME); } {letter}({alnum}|[_\-])*([\.]?({alnum}|[_\-]))* { return(IDENTIFIER); } -{alnum}*{letter}{alnum}* { return(FILESYSTEM); } {digit}+|0x{hexval}+ { return(NUMBER); } +{alnum}*{letter}{alnum}* { return(FILESYSTEM); } {digit}{1,3}(\.{digit}{1,3}){3} { return(IPV4_ADDR); } {hexval}{0,4}":"{hexval}{0,4}":"({hexval}|[:.])* { return(IPV6_ADDR); }{digit}+(\.({alnum}|[_.])*)? {
return(VERSION_IDENTIFIER); }
--
1.9.3_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].