Re: [PATCH] selinux: fix Null pointer deference at sidtab_convert_hashtable()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 13, 2024 at 7:01 PM Samasth Norway Ananda
<samasth.norway.ananda@xxxxxxxxxx> wrote:
>
> Handle the case where SID (Security Identifier) being looked up was
> not found in the SID-to-Domain mapping table.
>
> Fixes: 66f8e2f03c02 ("selinux: sidtab reverse lookup hash table")
> Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@xxxxxxxxxx>
> ---
> This error was found through static analysis tool and has only been
> compile tested.
> ---
>  security/selinux/ss/sidtab.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> index c8848cbba81f..b1fbdeaa8817 100644
> --- a/security/selinux/ss/sidtab.c
> +++ b/security/selinux/ss/sidtab.c
> @@ -367,6 +367,8 @@ static void sidtab_convert_hashtable(struct sidtab *s, u32 count)
>
>         for (i = 0; i < count; i++) {
>                 entry = sidtab_do_lookup(s, i, 0);
> +               if (!entry)
> +                       continue;
>                 entry->sid = index_to_sid(i);
>                 entry->hash = context_compute_hash(&entry->context);

The number of entries in a sidtab should never decrease, only increase
as new labels/contexts are put to use in the system.  With that in
mind, and looking at the only caller to sidtab_convert_hashtable(),
sidtab_convert(), we see that sidtab_convert_hashtable() will always
be called with a @count parameter that never larger than the size of
the hashtable (although it could be smaller).

-- 
paul-moore.com





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux