selinux: fix bug in conditional rules handling
PATCH 1/1 selinux: fix bug in conditional rules handling
commit fa1aa143ac4a ("selinux: extended permissions for ioctls") introduced a bug into the handling of conditional rules, skipping the processing entirely when the caller does not provide an extended permissions (xperms) structure. Access checks from userspace using /sys/fs/selinux/access do not include such a structure since that interface does not presently expose extended permission information. As a result, conditional rules were being ignored entirely on userspace access requests, producing denials when access was allowed by conditional rules in the policy. Fix the bug by only skipping computation of extended permissions in this situation, not the entire conditional rules processing.
--- security/selinux/ss/conditional.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/selinux/ss/conditional.c +2 -2
@@ -638,7 +638,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, {struct avtab_node *node; -if (!ctab || !key || !avd || !xperms) +if (!ctab || !key || !avd)return ; for (node = avtab_search_node(ctab, key); node;
@@ -657,7 +657,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key,if ((u16)(AVTAB_AUDITALLOW |AVTAB_ENABLED ) == (node->key.specified & (AVTAB_AUDITALLOW |AVTAB_ENABLED ))) avd->auditallow |= node->datum.u.data; -if ((node->key.specified &AVTAB_ENABLED ) && +if (xperms && (node->key.specified &AVTAB_ENABLED ) && (node->key.specified &AVTAB_XPERMS ))services_compute_xperms_drivers (xperms, node); }
Signature · 1 line
2.4.3
Paul Moore
maintainerQuoted 11 lines · Stephen Smalley
commit
fa1aa143ac4a("selinux: extended permissions for ioctls") introduced a bug into the handling of conditional rules, skipping the processing entirely when the caller does not provide an extended permissions (xperms) structure. Access checks from userspace using/sys/fs/selinux/accessdo not include such a structure since that interface does not presently expose extended permission information. As a result, conditional rules were being ignored entirely on userspace access requests, producing denials when access was allowed by conditional rules in the policy. Fix the bug by only skipping computation of extended permissions in this situation, not the entire conditional rules processing.
Quoted 5 lines
Reported-by Laurent Bigonville <[email protected]>Signed-off-by Stephen Smalley <[email protected]>--- security/selinux/ss/conditional.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Looks fine to me, thanks for the fix guys. I'm going to mark this for stable unless I hear a strong objection from anyone.
Quoted 25 lines
security/selinux/ss/conditional.c +2
-3@@ -638,7 +638,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, {struct avtab_node *node; -if (!ctab || !key || !avd || !xperms) +if (!ctab || !key || !avd)return ; for (node = avtab_search_node(ctab, key); node;@@ -657,7 +657,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key,if ((u16)(AVTAB_AUDITALLOW |AVTAB_ENABLED ) == (node->key.specified & (AVTAB_AUDITALLOW |AVTAB_ENABLED ))) avd->auditallow |= node->datum.u.data; -if ((node->key.specified &AVTAB_ENABLED ) && +if (xperms && (node->key.specified &AVTAB_ENABLED ) && (node->key.specified &AVTAB_XPERMS ))services_compute_xperms_drivers (xperms, node); } --2.4.3
Signature · 2 lines
paul moore www.paul-moore.com
Quoted 12 lines · Paul Moore
Quoted 11 lines · Stephen Smalley
commit
fa1aa143ac4a("selinux: extended permissions for ioctls") introduced a bug into the handling of conditional rules, skipping the processing entirely when the caller does not provide an extended permissions (xperms) structure. Access checks from userspace using/sys/fs/selinux/accessdo not include such a structure since that interface does not presently expose extended permission information. As a result, conditional rules were being ignored entirely on userspace access requests, producing denials when access was allowed by conditional rules in the policy. Fix the bug by only skipping computation of extended permissions in this situation, not the entire conditional rules processing.
Quoted 8 lines
Quoted 5 lines
Reported-by Laurent Bigonville <[email protected]>Signed-off-by Stephen Smalley <[email protected]>--- security/selinux/ss/conditional.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Looks fine to me, thanks for the fix guys. I'm going to mark this for stable unless I hear a strong objection from anyone.
Yes, definitely should go to stable.
Quoted 29 lines
Quoted 26 lines
security/selinux/ss/conditional.c +2
-3@@ -638,7 +638,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, {struct avtab_node *node; -if (!ctab || !key || !avd || !xperms) +if (!ctab || !key || !avd)return ; for (node = avtab_search_node(ctab, key); node;@@ -657,7 +657,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key,if ((u16)(AVTAB_AUDITALLOW |AVTAB_ENABLED ) == (node->key.specified & (AVTAB_AUDITALLOW |AVTAB_ENABLED ))) avd->auditallow |= node->datum.u.data; -if ((node->key.specified &AVTAB_ENABLED ) && +if (xperms && (node->key.specified &AVTAB_ENABLED ) && (node->key.specified &AVTAB_XPERMS ))services_compute_xperms_drivers (xperms, node); } --2.4.3
Quoted 11 lines · Stephen Smalley
commit
fa1aa143ac4a("selinux: extended permissions for ioctls") introduced a bug into the handling of conditional rules, skipping the processing entirely when the caller does not provide an extended permissions (xperms) structure. Access checks from userspace using/sys/fs/selinux/accessdo not include such a structure since that interface does not presently expose extended permission information. As a result, conditional rules were being ignored entirely on userspace access requests, producing denials when access was allowed by conditional rules in the policy. Fix the bug by only skipping computation of extended permissions in this situation, not the entire conditional rules processing.
Quoted 5 lines
Reported-by Laurent Bigonville <[email protected]>Signed-off-by Stephen Smalley <[email protected]>--- security/selinux/ss/conditional.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Merged into the SELinux stable branch, I'll push it to James tomorrow.
Quoted 22 lines
(quoted diff) +0
-0
b/security/selinux/ss/conditional.cindex 18643bf..456e1a9 100644security/selinux/ss/conditional.c +1
-1@@ -638,7 +638,7 @@ void cond_compute_av(struct avtab *ctab, struct avtab_key *key, {struct avtab_node *node; -if (!ctab || !key || !avd || !xperms) +if (!ctab || !key || !avd)return ; for (node = avtab_search_node(ctab, key); node;@@ -657,7 +657,7 @@ void cond_compute_av(struct avtab *ctab, struct
avtab_key*key, if ((u16)(AVTAB_AUDITALLOW|AVTAB_ENABLED) ==security/selinux/ss/conditional.c +1
-1(node->key.specified & (AVTAB_AUDITALLOW|AVTAB_ENABLED))) avd->auditallow |= node->datum.u.data; -if ((node->key.specified &AVTAB_ENABLED ) && +if (xperms && (node->key.specified &AVTAB_ENABLED ) && (node->key.specified &AVTAB_XPERMS ))services_compute_xperms_drivers (xperms, node); }
Signature · 2 lines
paul moore www.paul-moore.com