On Thu, Jun 11, 2020 at 11:58 AM <t...@redhat.com> wrote:
>
> From: Tom Rix <t...@redhat.com>
>
> Clang static analysis reports this double free error
>
> security/selinux/ss/conditional.c:139:2: warning: Attempt to free released 
> memory [unix.Malloc]
>         kfree(node->expr.nodes);
>         ^~~~~~~~~~~~~~~~~~~~~~~
>
> When cond_read_node fails, it calls cond_node_destroy which frees the
> node but does not poison the entry in the node list.  So when it
> returns to its caller cond_read_list, cond_read_list deletes the
> partial list.  The latest entry in the list will be deleted twice.
>
> So instead of freeing the node in cond_read_node, let list freeing in
> code_read_list handle the freeing the problem node along with all of the the
> earlier nodes.
>
> Signed-off-by: Tom Rix <t...@redhat.com>

Looks like this was introduced by
60abd3181db29ea81742106cc0ac2e27fd05b418 ("selinux: convert cond_list
to array").

Acked-by: Stephen Smalley <stephen.smalley.w...@gmail.com>

Reply via email to