Re: [PATCH] selinux: fix NULL-pointer dereference when hashtab allocation fails

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

 



On Fri, Nov 19, 2021 at 8:45 AM Ondrej Mosnacek <omosnace@xxxxxxxxxx> wrote:
>
> When the hash table slot array allocation fails in hashtab_init(),
> h->size is left initialized with a non-zero value, but the h->htable
> pointer is NULL. This may then cause a NULL pointer dereference, since
> the policydb code relies on the assumption that even after a failed
> hashtab_init(), hashtab_map() and hashtab_destroy() can be safely called
> on it. Yet, these detect an empty hashtab only by looking at the size.
>
> Fix this by making sure that hashtab_init() always leaves behind a valid
> empty hashtab when the allocation fails.
>
> Fixes: 03414a49ad5f ("selinux: do not allocate hashtabs dynamically")
> Signed-off-by: Ondrej Mosnacek <omosnace@xxxxxxxxxx>
> ---
>  security/selinux/ss/hashtab.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)

Looks good to me, merged into selinux/stable-5.16.  However, as it is
Friday, I'm going to hold of on sending this to Linus until early next
week.

-- 
paul moore
www.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