]> git.baikalelectronics.ru Git - kernel.git/commit
selinux: fix double free of cond_list on error paths
authorVratislav Bendel <vbendel@redhat.com>
Wed, 2 Feb 2022 11:25:11 +0000 (12:25 +0100)
committerPaul Moore <paul@paul-moore.com>
Wed, 2 Feb 2022 16:02:10 +0000 (11:02 -0500)
commitf3b161de25d7530855b87aa5866a9559d0b7b37e
tree138762ec92ee3a0a054d3809e235a90db82259d7
parent991a5e519c2aa1f4ed2bf6e2139997d7e7967cb3
selinux: fix double free of cond_list on error paths

On error path from cond_read_list() and duplicate_policydb_cond_list()
the cond_list_destroy() gets called a second time in caller functions,
resulting in NULL pointer deref.  Fix this by resetting the
cond_list_len to 0 in cond_list_destroy(), making subsequent calls a
noop.

Also consistently reset the cond_list pointer to NULL after freeing.

Cc: stable@vger.kernel.org
Signed-off-by: Vratislav Bendel <vbendel@redhat.com>
[PM: fix line lengths in the description]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/conditional.c