checkpolicy constraints bug
constrain process transition
( r1 == r2 or ( t1 == privrole and t2 == userdomain )
ifdef(`crond.te', `
or (t1 == crond_t and t2 == user_crond_domain)
')
ifdef(`userhelper.te',
`or (t1 == userhelperdomain)')
ifdef(`postfix.te', `
ifdef(`direct_sysadm_daemon',
`or (t1 == sysadm_mail_t and t2 == system_mail_t and r2 == system_r )')
')
or (t1 == priv_system_role and r2 == system_r )
);The above section in the constraints file for the strict policy works with checkpolicy version 1.23.1-1 (FC4 release) but fails with 1.25.3-1 (latest rawhide).
type=AVC msg=audit(1123680529.941:1493682): avc: denied { transition } for pid=3242 comm="bash" name="sshd" dev=dm-0 ino=69461 scontext=root:sysadm_r:sysadm_t tcontext=root:system_r:initrc_t tclass=process
type=SYSCALL msg=audit(1123680529.941:1493682): arch=40000003 syscall=11 success=no exit=-13 a0=8cbea88 a1=8cbd2c8 a2=8cbbc30 a3=1 items=1 pid=3242 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 comm="bash" exe="/bin/bash"
type=AVC_PATH msg=audit(1123680529.941:1493682): path="/etc/rc.d/init.d/sshd" type=CWD msg=audit(1123680529.941:1493682): cwd="/root" type=PATH msg=audit(1123680529.941:1493682): item=0 name="/etc/init.d/sshd" flags=101 inode=69461 dev=fd:00 mode=0100755 ouid=0 ogid=0 rdev=00:00
Above is the relevant section from the audit.log file. Nothing else changed apart from the checkpolicy version, downgrading to the old version makes checkpolicy produce a binary policy that works.
I will be happy to provide the policy.conf as well as both versions of the binary if desired.
Signature · 9 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 15 lines · Russell Coker
constrain process transition
( r1 == r2 or ( t1 == privrole and t2 == userdomain ) ifdef(`crond.te', ` or (t1 == crond_t and t2 == user_crond_domain) ') ifdef(`userhelper.te', `or (t1 == userhelperdomain)') ifdef(`postfix.te', ` ifdef(`direct_sysadm_daemon', `or (t1 == sysadm_mail_t and t2 == system_mail_t and r2 == system_r )') ') or (t1 == priv_system_role and r2 == system_r ) );
Quoted 3 lines
The above section in the constraints file for the strict policy works with checkpolicy version 1.23.1-1 (FC4 release) but fails with 1.25.3-1 (latest rawhide).
Yes, reproduced it here as well. Looks like a bug in the module expansion code for constraint sets. I have a patch in testing now.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 16 lines · Stephen Smalley
Quoted 15 lines · Russell Coker
constrain process transition
( r1 == r2 or ( t1 == privrole and t2 == userdomain ) ifdef(`crond.te', ` or (t1 == crond_t and t2 == user_crond_domain) ') ifdef(`userhelper.te', `or (t1 == userhelperdomain)') ifdef(`postfix.te', ` ifdef(`direct_sysadm_daemon', `or (t1 == sysadm_mail_t and t2 == system_mail_t and r2 == system_r )') ') or (t1 == priv_system_role and r2 == system_r ) );
Quoted 6 lines
Quoted 3 lines
The above section in the constraints file for the strict policy works with checkpolicy version 1.23.1-1 (FC4 release) but fails with 1.25.3-1 (latest rawhide).
Yes, reproduced it here as well. Looks like a bug in the module expansion code for constraint sets. I have a patch in testing now.
Ok, I believe that the patch below fixes this bug; the constraint expansion code was erroneously clobbering non-type sets and leading to a failure of the last clause of the constraint, preventing the transition. This is being committed to libsepol 1.7.12, and checkpolicy will require a rebuild since it links with the static lib.
Signature · 2 lines
Stephen Smalley National Security Agency
Index: libsepol/ChangeLog
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/ChangeLog,v retrieving revision 1.43
retrieving revision 1.44
ChangeLog +3 -0
@@ -1,3 +1,6 @@ +1.7.12 2004-08-10 + * Fixed bug in constraint_node_clone handling of name sets. + 1.7.11 2004-08-08 * Fix range_trans_clone to map the type values properly.
Index: libsepol/VERSION
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/VERSION,v retrieving revision 1.38
retrieving revision 1.39
VERSION +1 -1
@@ -1 +1 @@ -1.7.11 +1.7.12
Index: libsepol/libsepol.spec
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/libsepol.spec,v retrieving revision 1.40
retrieving revision 1.41
libsepol.spec +1 -1
@@ -1,6 +1,6 @@ Summary: SELinux binary policy manipulation library Name: libsepol -Version: 1.7.11 +Version: 1.7.12 Release: 1 License: LGPL Group: System Environment/Libraries
Index: libsepol/include/sepol/constraint.h
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/include/sepol/constraint.h,v retrieving revision 1.4
retrieving revision 1.5
include/sepol/constraint.h +0 -2
@@ -72,8 +72,6 @@ struct policydb;extern int constraint_expr_init (constraint_expr_t *expr);extern void constraint_expr_destroy (constraint_expr_t *expr); -extern int expand_constraint (constraint_expr_t *expr,constraint_expr_t *dest_expr, -uint32_t *typemap,struct policydb *pol);#endif /* _CONSTRAINT_H_ */
Index: libsepol/src/constraint.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/constraint.c,v retrieving revision 1.3
retrieving revision 1.4
src/constraint.c +0 -46
49 lines not on this page · raw message
Index: libsepol/src/expand.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/expand.c,v retrieving revision 1.3
retrieving revision 1.4
src/expand.c +11 -20
@@ -230,31 +230,22 @@ static int constraint_node_clone(constra new_expr->expr_type = expr->expr_type; new_expr->attr = expr->attr; new_expr->op = expr->op; -/* If the constraint expression indicates a -type name, remap the corresponding 'names' -bitmap from old to new by way of the -typemap. Note that if a name is actually -an attribute, one needs to remap the -/components/ of that attribute as well. */ if (new_expr->expr_type ==CEXPR_NAMES ) {if (new_expr->attr &CEXPR_TYPE ) { -if (expand_constraint (expr, new_expr, - state->typemap, state->base)) { - goto out_of_mem; - } - } -else { -if (ebitmap_union (&new_expr->names, - &expr->names)) { +/* Type sets require expansion and conversion. */ +if (expand_convert_type_set (state->base, + state->typemap, + expr->type_names, + &new_expr->names)) { + goto out_of_mem; + } + }else { +/* Other kinds of sets do not. */ +if (ebitmap_cpy (&new_expr->names, + &expr->names)) { goto out_of_mem; } } -if (expand_convert_type_set (state->base, - state->typemap, - expr->type_names, - &new_expr->names)) { - goto out_of_mem; - } }if (expr_l) { expr_l->next = new_expr;