selinux/checkpolicy
James Carter 6f2b689f63 checkpolicy: Fix MLS users in optional blocks
When a user is created in an optional block, a user datum is added
to both the avrule_decl's symtab and the policydb's symtab, but
the semantic MLS information is only added to the avrule_decl's
user datum. This causes an error to occur during policy expansion
when user_copy_callback() is called. If this error did not occur
then the policydb's user datum would be written without any MLS
info and the policy would fail validation when read later.

When creating a user datum, search for a user datum with the same
key in the policydb's symtab. If that datum has no MLS information,
then copy the MLS information from the avrule_decl's datum. If it
does, then compare the default level, low level, and high level
sensitivities and give an error if they do not match. There is not
enough information to expand the categories for the high and low
levels, so merge the semantic categories. If the two category sets
are not equal an error will occur during the expansion phase.

A minimum policy to demonstrate the bug:
class CLASS1
sid kernel
class CLASS1 { PERM1 }
sensitivity SENS1;
dominance { SENS1 }
level SENS1;
mlsconstrain CLASS1 { PERM1 } ((h1 dom h2) and (l1 domby h1));
type TYPE1;
allow TYPE1 self : CLASS1 PERM1;
role ROLE1;
role ROLE1 types TYPE1;
optional {
  require {
    role ROLE1;
  }
  user USER2 roles ROLE1 level SENS1 range SENS1;
}
user USER1 roles ROLE1 level SENS1 range SENS1;
sid kernel USER1:ROLE1:TYPE1:SENS1

Signed-off-by: James Carter <jwcart2@gmail.com>
2024-11-15 13:25:48 -05:00
..
fuzz checkpolicy/fuzz: fix setjmp condition 2024-10-30 08:04:38 -04:00
test libsepol: Support nlmsg extended permissions 2024-09-04 16:54:26 -04:00
tests checkpolicy: support CIDR notation for nodecon statements 2024-05-24 08:46:34 -04:00
.gitignore checkpolicy: add round-trip tests 2023-11-07 16:27:26 -05:00
LICENSE
Makefile checkpolicy: add libfuzz based fuzzer 2024-03-04 09:54:47 -05:00
VERSION Release 3.7 2024-06-26 17:30:41 +02:00
checkmodule.8
checkmodule.c checkpolicy: drop global policyvers variable 2024-05-01 16:48:25 -04:00
checkpolicy.8
checkpolicy.c checkpolicy: drop global policyvers variable 2024-05-01 16:48:25 -04:00
module_compiler.c checkpolicy: drop union stack_item_u 2024-04-04 11:17:50 -04:00
module_compiler.h checkpolicy: add libfuzz based fuzzer 2024-03-04 09:54:47 -05:00
parse_util.c checkpolicy: cleanup resources on parse error 2024-03-04 09:54:52 -05:00
parse_util.h
policy_define.c checkpolicy: Fix MLS users in optional blocks 2024-11-15 13:25:48 -05:00
policy_define.h checkpolicy: support CIDR notation for nodecon statements 2024-05-24 08:46:34 -04:00
policy_parse.y checkpolicy: support CIDR notation for nodecon statements 2024-05-24 08:46:34 -04:00
policy_scan.l checkpolicy: support CIDR notation for nodecon statements 2024-05-24 08:46:34 -04:00
queue.c
queue.h