selinux/libsepol/include/sepol
James Carter fe16f586d5 checkpolicy, libsepol: Fix potential double free of mls_level_t
In checkpolicy, a sensitivity that has one or more aliases will
temporarily share the mls_level_t structure with its aliases until
a level statement is processed for the sensitivity (or one of the
aliases) and the aliases are updated to have their own mls_level_t
structure. If the policydb is destroyed while they are sharing the
mls_level_t structure, then a double free of the shared mls_level_t
will occur. This does not currently occur only because checkpolicy
does very little clean-up before exiting.

The "defined" field of the level_datum_t is set after a level
statement is processed for a sensitivity and its aliases. This means
that we know an alias has its own mls_level_t if the "defined" field
is set. The double free can be avoided by not destroying the
mls_leve_t structure for an alias unless the "defined" field is set.

Since the "defined" field is only set to false while the mls_level_t
structure is being shared, it would be clearer to rename the field
as "notdefined". It would only be set during the time the sensitivity
and its aliases are sharing the mls_level_t structure. Outside of
checkpolicy, the "notdefined" field will always be set to 0.

Also, do more validation of the level_datum_t when validating the
policydb.

Signed-off-by: James Carter <jwcart2@gmail.com>
2024-03-04 10:01:59 -05:00
..
policydb checkpolicy, libsepol: Fix potential double free of mls_level_t 2024-03-04 10:01:59 -05:00
boolean_record.h
booleans.h libsepol: Drop deprecated functions 2020-10-19 22:11:39 +02:00
context_record.h
context.h
debug.h
errcodes.h libsepol: enclose macro parameters and replacement lists in parentheses 2022-08-09 09:52:06 -04:00
handle.h
ibendport_record.h libsepol: replace non-standard use of __BEGIN_DECLS 2017-06-20 11:03:12 -04:00
ibendports.h libsepol: replace non-standard use of __BEGIN_DECLS 2017-06-20 11:03:12 -04:00
ibpkey_record.h libsepol: replace non-standard use of __BEGIN_DECLS 2017-06-20 11:03:12 -04:00
ibpkeys.h libsepol: replace non-standard use of __BEGIN_DECLS 2017-06-20 11:03:12 -04:00
iface_record.h
interfaces.h
kernel_to_cil.h
kernel_to_conf.h
module_to_cil.h
module.h
node_record.h
nodes.h
policydb.h libsepol: add a function to optimize kernel policy 2019-06-25 10:11:00 -04:00
port_record.h selinux: Add support for the SCTP portcon keyword 2018-03-19 12:34:29 -04:00
ports.h
sepol.h semanage: Update semanage to allow runtime labeling of ibendports 2017-05-23 16:20:55 -04:00
user_record.h
users.h libsepol: Drop deprecated functions 2020-10-19 22:11:39 +02:00