* [PATCH v2] libsepol: Validate any levels that appear in a policy
@ 2026-08-05 14:36 James Carter
2026-08-05 15:03 ` Stephen Smalley
0 siblings, 1 reply; 2+ messages in thread
From: James Carter @ 2026-08-05 14:36 UTC (permalink / raw)
To: selinux; +Cc: stephen.smalley.work, James Carter
Policy validation only validates levels for MLS policies, but it
is easy to create a non-mls policy with levels (just read the
policy in, change the "mls" field of the policydb to 0, and write
the policy out). A maliciously crafted non-mls policy could have
levels that cause an OOB access when processed.
Because of this, validate any levels that appear in any policy,
even if it is a non-mls policy.
Signed-off-by: James Carter <jwcart2@gmail.com>
---
v2: - Old subject line "libsepol: Non-mls polcies should not have any levels"
no longer fits.
- Don't differentiate between mls and non-mls policies just validate any
levels that are in the policy
libsepol/src/policydb_validate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
index fc66a4c7..ea53da86 100644
--- a/libsepol/src/policydb_validate.c
+++ b/libsepol/src/policydb_validate.c
@@ -1024,8 +1024,8 @@ static int validate_datum_array_entries(sepol_handle_t *handle,
&margs))
goto bad;
- if (p->mls && hashtab_map(symtabs[SYM_LEVELS].table,
- validate_level_datum_wrapper, &margs))
+ if (hashtab_map(symtabs[SYM_LEVELS].table,
+ validate_level_datum_wrapper, &margs))
goto bad;
if (hashtab_map(symtabs[SYM_CATS].table, validate_datum,
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] libsepol: Validate any levels that appear in a policy
2026-08-05 14:36 [PATCH v2] libsepol: Validate any levels that appear in a policy James Carter
@ 2026-08-05 15:03 ` Stephen Smalley
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Smalley @ 2026-08-05 15:03 UTC (permalink / raw)
To: James Carter; +Cc: selinux
On Wed, Aug 5, 2026 at 10:36 AM James Carter <jwcart2@gmail.com> wrote:
>
> Policy validation only validates levels for MLS policies, but it
> is easy to create a non-mls policy with levels (just read the
> policy in, change the "mls" field of the policydb to 0, and write
> the policy out). A maliciously crafted non-mls policy could have
> levels that cause an OOB access when processed.
>
> Because of this, validate any levels that appear in any policy,
> even if it is a non-mls policy.
>
> Signed-off-by: James Carter <jwcart2@gmail.com>
Needs to be reformatted via make format but otherwise,
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> ---
> v2: - Old subject line "libsepol: Non-mls polcies should not have any levels"
> no longer fits.
> - Don't differentiate between mls and non-mls policies just validate any
> levels that are in the policy
>
> libsepol/src/policydb_validate.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
> index fc66a4c7..ea53da86 100644
> --- a/libsepol/src/policydb_validate.c
> +++ b/libsepol/src/policydb_validate.c
> @@ -1024,8 +1024,8 @@ static int validate_datum_array_entries(sepol_handle_t *handle,
> &margs))
> goto bad;
>
> - if (p->mls && hashtab_map(symtabs[SYM_LEVELS].table,
> - validate_level_datum_wrapper, &margs))
> + if (hashtab_map(symtabs[SYM_LEVELS].table,
> + validate_level_datum_wrapper, &margs))
> goto bad;
>
> if (hashtab_map(symtabs[SYM_CATS].table, validate_datum,
> --
> 2.55.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-05 15:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 14:36 [PATCH v2] libsepol: Validate any levels that appear in a policy James Carter
2026-08-05 15:03 ` Stephen Smalley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.