libsepol: fix checkpolicy dontaudit compiler bug
PATCH v5 1/1 libsepol: fix checkpolicy dontaudit compiler bug
From: William Roberts <[email protected]>
The combining logic for dontaudit rules was wrong, causing a dontaudit A B:C *; rule to be clobbered by a dontaudit A B:C p; rule.
This is a reimplementation of:
commit 6201bb5e258e2b5bcc04d502d6fbc05c69d21d71 ("libsepol:
fix checkpolicy dontaudit compiler bug")
that avoids the cumbersome pointer assignments on alloced.
--- libsepol/src/expand.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
libsepol/src/expand.c +7 -4
@@ -1640,6 +1640,12 @@ static avtab_ptr_t find_avtab_node(sepol_handle_t * handle,if (!node) {memset (&avdatum,0 ,sizeof avdatum); +/* +* AUDITDENY and DONTAUDIT are &= assigned, versus |= for +* others. Initialize the data accordingly. +*/ + avdatum.data = (key->specified & + (AVRULE_AUDITDENY |AVRULE_DONTAUDIT )) ? ~0 :0 ;/* this is used to get the node - insertion is actually unique */ node =avtab_insert_nonunique (avtab, key, &avdatum);if (!node) {
@@ -1850,10 +1856,7 @@ static int expand_avrule_helper(sepol_handle_t * handle,*/ avdatump->data &= cur->data; }else if (specified &AVRULE_DONTAUDIT ) { -if (avdatump->data) - avdatump->data &= ~cur->data; -else - avdatump->data = ~cur->data; + avdatump->data &= ~cur->data; }else if (specified &AVRULE_XPERMS ) { xperms = avdatump->xperms;if (!xperms) {
Signature · 1 line
2.7.4
<snip>
libsepol/src/expand.c static avtab_ptr_t find_avtab_node(sepol_handle_t * handle, · line 1648
Quoted 7 lines
memset(&avdatum, 0, sizeof avdatum);libsepol/src/expand.c +6
-0+/* +* AUDITDENY and DONTAUDIT are &= assigned, versus |= for +* others. Initialize the data accordingly. +*/ + avdatum.data = (key->specified & + (AVRULE_AUDITDENY |AVRULE_DONTAUDIT )) ? ~0 :0 ;
Nak this, surprising this is working and producing correct output, but we would want to check
against the AVTAB defines...
This patch, while simple, for some reason is getting the best of me :-P
Quoted 3 lines
/* this is used to get the node - insertion is actually unique */
node = avtab_insert_nonunique(avtab, key, &avdatum);
if (!node) {<snip>
Quoted 6 lines · William Roberts
<snip>
Review
Quoted 3 lines
memset(&avdatum, 0, sizeof avdatum);(quoted diff) +2
-0+ /* + * AUDITDENY and DONTAUDIT are &= assigned, versus |=
for
Quoted 4 lines
libsepol/src/expand.c static avtab_ptr_t find_avtab_node(sepol_handle_t * handle,
Quoted 4 lines
libsepol/src/expand.c +4
-0+* others. Initialize the data accordingly. +*/ + avdatum.data = (key->specified & + (AVRULE_AUDITDENY | AVRULE_DONTAUDIT)) ?
~0 : 0;
Quoted 2 lines
Nak this, surprising this is working and producing correct output, but
Correct when checking the sesearch output, which makes sense since we're expecting both classes to be all dontaudit statements.
Quoted 6 lines
we would want to check
against the AVTAB defines...This patch, while simple, for some reason is getting the best of me :-P
Quoted 1 line
/* this is used to get the node - insertion is actually
unique */
Quoted 3 lines
Quoted 2 lines
node = avtab_insert_nonunique(avtab, key, &avdatum); if (!node) {<snip>