Commit a0199cf0 authored by Kalesh Singh's avatar Kalesh Singh
Browse files

UPSTREAM: tracing/histogram: Fix UAF in destroy_hist_field()

Calling destroy_hist_field() on an expression will recursively free
any operands associated with the expression. If during expression
parsing the operands of the expression are already set when an error
is encountered, there is no need to explicity free the operands. Doing
so will result in destroy_hist_field() being called twice for the
operands and lead to a use-after-free (UAF) error.

If the operands are associated with the expression, only call
destroy_hist_field() on the expression since the operands will be
recursively freed.

Link: https://lore.kernel.org/all/CAHk-=wgcrEbFgkw9720H3tW-AhHOoEKhYwZinYJw4FpzSaJ6_Q@mail.gmail.com/
Link: https://lkml.kernel.org/r/20211118011542.1420131-1-kaleshsingh@google.com



Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
Fixes: 8b5d46fd ("tracing/histogram: Optimize division by constants")
Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
(cherry picked from commit f86b0aaa)

Bug: 146055070
Bug: 145972256
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
Change-Id: I007b17b31e56a1571f91c97993a7fd1fe1140f43
parent c2a29c3b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment