SELinux Archive mirror
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: "Christian Göttsche" <cgzones@googlemail.com>
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH] libsepol: validate common classes in scope indices
Date: Fri, 8 Dec 2023 15:02:21 -0500	[thread overview]
Message-ID: <CAP+JOzTCBjUjO1uUdN4-qb5Q3nBiodeOxr-L-_DkDoGX_-Dcvg@mail.gmail.com> (raw)
In-Reply-To: <20231208151831.48343-1-cgzones@googlemail.com>

On Fri, Dec 8, 2023 at 10:19 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Validate common classes inside scope indices similar to all other symbol
> table types.
>
> Reported-by: oss-fuzz (issue 64849)
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
> This probably also resolves issue 64854, which I could not reproduce
> locally.
> ---
>  libsepol/include/sepol/policydb/policydb.h | 1 +
>  libsepol/src/policydb_validate.c           | 2 ++
>  2 files changed, 3 insertions(+)
>
> diff --git a/libsepol/include/sepol/policydb/policydb.h b/libsepol/include/sepol/policydb/policydb.h
> index 6682069e..658b25d4 100644
> --- a/libsepol/include/sepol/policydb/policydb.h
> +++ b/libsepol/include/sepol/policydb/policydb.h
> @@ -430,6 +430,7 @@ typedef struct genfs {
>   * subtract one) into the global policydb->scope array. */
>  typedef struct scope_index {
>         ebitmap_t scope[SYM_NUM];
> +#define p_commons_scope scope[SYM_COMMONS]
>  #define p_classes_scope scope[SYM_CLASSES]
>  #define p_roles_scope scope[SYM_ROLES]
>  #define p_types_scope scope[SYM_TYPES]
> diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
> index bd8e9f8f..4919f674 100644
> --- a/libsepol/src/policydb_validate.c
> +++ b/libsepol/src/policydb_validate.c
> @@ -1344,6 +1344,8 @@ bad:
>
>  static int validate_scope_index(sepol_handle_t *handle, const scope_index_t *scope_index, validate_t flavors[])
>  {
> +       if (validate_ebitmap(&scope_index->p_commons_scope, &flavors[SYM_COMMONS]))
> +               goto bad;

As far as I know, there will never be any commons in the scope index,
so it would be better to just check that it is empty.

Thanks,
Jim


>         if (validate_ebitmap(&scope_index->p_classes_scope, &flavors[SYM_CLASSES]))
>                 goto bad;
>         if (validate_ebitmap(&scope_index->p_roles_scope, &flavors[SYM_ROLES]))
> --
> 2.43.0
>
>

      reply	other threads:[~2023-12-08 20:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 15:18 [PATCH] libsepol: validate common classes in scope indices Christian Göttsche
2023-12-08 20:02 ` James Carter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP+JOzTCBjUjO1uUdN4-qb5Q3nBiodeOxr-L-_DkDoGX_-Dcvg@mail.gmail.com \
    --to=jwcart2@gmail.com \
    --cc=cgzones@googlemail.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).