selinux: make nslot handling in avtab more robust
authorOndrej Mosnacek <omosnace@redhat.com>
Fri, 2 Apr 2021 08:56:18 +0000 (10:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Apr 2021 06:41:57 +0000 (08:41 +0200)
commit4f29b08e238fdd2ed8cbbd4fa2d4ab51b0ddef1f
treec980df0c852c65d02d1d8c82f18256b595fe9218
parenta12a2fa9a129d3200065fde95f6eb0a98672a2c3
selinux: make nslot handling in avtab more robust

commit 442dc00f82a9727dc0c48c44f792c168f593c6df upstream.

1. Make sure all fileds are initialized in avtab_init().
2. Slightly refactor avtab_alloc() to use the above fact.
3. Use h->nslot == 0 as a sentinel in the access functions to prevent
   dereferencing h->htable when it's not allocated.

Cc: stable@vger.kernel.org
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/selinux/ss/avtab.c