]> git.baikalelectronics.ru Git - kernel.git/commit
selinux: fix NULL dereference in policydb_destroy()
authorOndrej Mosnacek <omosnace@redhat.com>
Sun, 17 Mar 2019 13:46:53 +0000 (14:46 +0100)
committerPaul Moore <paul@paul-moore.com>
Mon, 18 Mar 2019 16:19:48 +0000 (12:19 -0400)
commit3ae72255c45ac4fd2add916c719200ac1e5e68b3
tree960c8d62d8a57248005a8f626b79b4eb37d53dea
parente34ba0d7c8ee128a8a7cc0a1d0345206aeb6a4e5
selinux: fix NULL dereference in policydb_destroy()

The conversion to kvmalloc() forgot to account for the possibility that
p->type_attr_map_array might be null in policydb_destroy().

Fix this by destroying its contents only if it is not NULL.

Also make sure ebitmap_init() is called on all entries before
policydb_destroy() can be called. Right now this is a no-op, because
both kvcalloc() and ebitmap_init() just zero out the whole struct, but
let's rather not rely on a specific implementation.

Reported-by: syzbot+a57b2aff60832666fc28@syzkaller.appspotmail.com
Fixes: 2b94b5d5200d ("selinux: convert to kvmalloc")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/policydb.c