Re: [PATCH] libsepol: Turn assert into error in type_set_expand()
James Carter <[email protected]> Thu, 30 Jul 2026 08:25:22 -0400
| Newsgroups | org.kernel.vger.selinux |
|---|---|
| Message-ID | <CAP+JOzSQibGghmGu8bDdxXiGO5zR9DXW2nLZNwUc594tCvVD0A@mail.gmail.com> |
On Wed, Jul 29, 2026 at 4:00 PM Stephen Smalley <[email protected]> wrote: > > On Wed, Jul 29, 2026 at 3:37 PM James Carter <[email protected]> wrote: > > > > 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]> > > --- > > libsepol/src/expand.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c > > index 8d7fe519..19b5fdcc 100644 > > --- a/libsepol/src/expand.c > > +++ b/libsepol/src/expand.c > > @@ -2827,8 +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)); > > - continue; > > + if (ebitmap_get_bit(t, i)) > > + goto err_neg; > > Why did you drop the continue; in the non-error path? That was a mistake. I'll send out a correction. Jim > > > } > > if (ebitmap_get_bit(t, i)) { > > if (ebitmap_set_bit(t, i, 0)) > > -- > > 2.55.0 > >