[PATCH v2] libsepol: Turn assert into error in type_set_expand()
James Carter <[email protected]> Thu, 30 Jul 2026 08:57:12 -0400
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <[email protected]> |
The assertion in function type_set_expand() can only be violated by a malformed policy. Since it is called before the policy has been validated just return an error. Signed-off-by: James Carter <[email protected]> --- v2: Do not delete the continue libsepol/src/expand.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c index 8d7fe519..7883dbc5 100644 --- a/libsepol/src/expand.c +++ b/libsepol/src/expand.c @@ -2827,7 +2827,8 @@ int type_set_expand(type_set_t *set, ebitmap_t *t, policydb_t *p, for (i = 0; i < p->p_types.nprim; i++) { if (p->type_val_to_struct[i] && p->type_val_to_struct[i]->flavor == TYPE_ATTRIB) { - assert(!ebitmap_get_bit(t, i)); + if (ebitmap_get_bit(t, i)) + goto err_neg; continue; } if (ebitmap_get_bit(t, i)) { -- 2.55.0