Re: [PATCH] libsepol/cil: Return SEPOL_ERR on failure to set bit

Stephen Smalley <[email protected]> Mon, 27 Jul 2026 13:56:26 -0400
Newsgroups org.kernel.vger.selinux
Message-ID <CAEjxPJ4AxjisR+VCNhS7mLCFmBOZhiWV4opHTtVmu1OD0ZLYug@mail.gmail.com>
On Mon, Jul 27, 2026 at 1:39 PM James Carter <[email protected]> wrote:
>
> The functions cil_typepermissive_to_policydb() and
> cil_typeneveraudit_to_policydb() return rc when ebitmap_set_bit()
> fails, but the rc value at the point is SEPOL_OK.
>
> Return SEPOL_ERR instead of rc when ebitmap_set_bit() fails.
>
> Signed-off-by: James Carter <[email protected]>

Acked-by: Stephen Smalley <[email protected]>

> ---
>  libsepol/cil/src/cil_binary.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
> index caf2d987..7ec3e781 100644
> --- a/libsepol/cil/src/cil_binary.c
> +++ b/libsepol/cil/src/cil_binary.c
> @@ -614,7 +614,7 @@ int cil_typepermissive_to_policydb(policydb_t *pdb,
>                 return rc;
>
>         if (ebitmap_set_bit(&pdb->permissive_map, sepol_type->s.value, 1)) {
> -               return rc;
> +               return SEPOL_ERR;
>         }
>
>         return SEPOL_OK;
> @@ -632,7 +632,7 @@ int cil_typeneveraudit_to_policydb(policydb_t *pdb,
>                 return rc;
>
>         if (ebitmap_set_bit(&pdb->neveraudit_map, sepol_type->s.value, 1)) {
> -               return rc;
> +               return SEPOL_ERR;
>         }
>
>         return SEPOL_OK;
> --
> 2.55.0
>