libsepol: fix checkpolicy dontaudit compiler bug
PATCH v6 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
libsepol/src/expand.c +6 -4
@@ -1640,6 +1640,11 @@ static avtab_ptr_t find_avtab_node(sepol_handle_t * handle,if (!node) {memset (&avdatum,0 ,sizeof avdatum); +/* +* AUDITDENY, aka DONTAUDIT, are &= assigned, versus |= for +* others. Initialize the data accordingly. +*/ + avdatum.data = key->specified ==AVTAB_AUDITDENY ? ~0 :0 ;/* this is used to get the node - insertion is actually unique */ node =avtab_insert_nonunique (avtab, key, &avdatum);if (!node) {
@@ -1850,10 +1855,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
libsepol/src/expand.c static avtab_ptr_t find_avtab_node(sepol_handle_t
Quoted 23 lines · On Nov 15, 2016 4:43 PM, <[email protected]> wrote:
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:
commit6201bb5e258e2b5bcc04d502d6fbc05c69d21d71("libsepol:
fix checkpolicy dontaudit compiler bug")
that avoids the cumbersome pointer assignments on alloced.Reported-by Nick Kralevich <[email protected]>Signed-off-by William Roberts <[email protected]>--- libsepol/src/expand.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)libsepol/src/expand.c +0
-0@@ -1640,6 +1640,11 @@ static avtab_ptr_t find_avtab_node(sepol_handle_t
* handle,
libsepol/src/expand.c static avtab_ptr_t find_avtab_node(sepol_handle_t * handle,
Quoted 5 lines
libsepol/src/expand.c +2
-0if (!node) {memset (&avdatum,0 ,sizeof avdatum); +/* +* AUDITDENY, aka DONTAUDIT, are &= assigned, versus |=
for
libsepol/src/expand.c static avtab_ptr_t find_avtab_node(sepol_handle_t * handle,
Quoted 4 lines
libsepol/src/expand.c +3
-0+* others. Initialize the data accordingly. +*/ + avdatum.data = key->specified ==AVTAB_AUDITDENY ? ~0 :0 ;/* this is used to get the node - insertion is actually
unique */
libsepol/src/expand.c static int expand_avrule_helper(sepol_handle_t *
Quoted 3 lines
libsepol/src/expand.c +0
-0node =avtab_insert_nonunique (avtab, key, &avdatum);if (!node) {@@ -1850,10 +1855,7 @@ static int expand_avrule_helper(sepol_handle_t *
handle,
Quoted 12 lines
libsepol/src/expand.c +1
-5*/ 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) { --
Quoted 2 lines
2.7.4
This patch has the same sesearch and policy file md5sums compared to master and after reverting + applying this.
Quoted 5 lines
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to
Stephen Smalley
AppliedQuoted 10 lines · On 11/15/2016 07:42 PM, [email protected] wrote:
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:
commit6201bb5e258e2b5bcc04d502d6fbc05c69d21d71("libsepol:
fix checkpolicy dontaudit compiler bug")
that avoids the cumbersome pointer assignments on alloced.
Thanks, applied both patches (revert and reimplementation).
Quoted 12 lines
Reported-by Nick Kralevich <[email protected]>Signed-off-by William Roberts <[email protected]>--- libsepol/src/expand.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)libsepol/src/expand.c +0
-0
libsepol/src/expand.c static avtab_ptr_t find_avtab_node(sepol_handle_t * handle, · line 1647
Quoted 8 lines
libsepol/src/expand.c +5
-0@@ -1640,6 +1640,11 @@ static avtab_ptr_t find_avtab_node(sepol_handle_t * handle,if (!node) {memset (&avdatum,0 ,sizeof avdatum); +/* +* AUDITDENY, aka DONTAUDIT, are &= assigned, versus |= for +* others. Initialize the data accordingly. +*/ + avdatum.data = key->specified ==AVTAB_AUDITDENY ? ~0 :0 ;
normally I'd parenthesize this, although it isn't strictly needed.
Quoted 16 lines
libsepol/src/expand.c +1
-4/* this is used to get the node - insertion is actually unique */ node =avtab_insert_nonunique (avtab, key, &avdatum);if (!node) {@@ -1850,10 +1855,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) {
Quoted 7 lines · Stephen Smalley
Quoted 6 lines · On 11/15/2016 07:42 PM, [email protected] wrote:
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.
Quoted 6 lines
Quoted 4 lines
This is a reimplementation of:
commit6201bb5e258e2b5bcc04d502d6fbc05c69d21d71("libsepol:
fix checkpolicy dontaudit compiler bug")
that avoids the cumbersome pointer assignments on alloced.Thanks, applied both patches (revert and reimplementation).
These line numbers might not line up, but it was inconsistent, so I didn't know:
1702: typemap ? typemap[cur->data - 1] : cur->data;
2958: to_be_appended = (cur_state == 1) ?
<snip>