Skip to content

Commit

Permalink
tracing/boot: Fix trace_boot_hist_add_array() to check array is value
Browse files Browse the repository at this point in the history
trace_boot_hist_add_array() uses the combination of
xbc_node_find_child() and xbc_node_get_child() to get the
child node of the key node. But since it missed to check
the child node is data node or not, user can pass the
subkey node for the array node (anode).
To avoid this issue, check the array node is a data node.
Actually, there is xbc_node_find_value(node, key, vnode),
which ensures the @vnode is a value node, so use it in
trace_boot_hist_add_array() to fix this issue.

Link: https://lkml.kernel.org/r/163119458308.161018.1516455973625940212.stgit@devnote2

Fixes: e66ed86 ("tracing/boot: Add per-event histogram action options")
Signed-off-by: Masami Hiramatsu <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
mhiramat authored and rostedt committed Sep 9, 2021
1 parent cfd7998 commit a3928f8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions kernel/trace/trace_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,12 @@ static int __init
trace_boot_hist_add_array(struct xbc_node *hnode, char **bufp,
char *end, const char *key)
{
struct xbc_node *knode, *anode;
struct xbc_node *anode;
const char *p;
char sep;

knode = xbc_node_find_child(hnode, key);
if (knode) {
anode = xbc_node_get_child(knode);
p = xbc_node_find_value(hnode, key, &anode);
if (p) {
if (!anode) {
pr_err("hist.%s requires value(s).\n", key);
return -EINVAL;
Expand Down

0 comments on commit a3928f8

Please sign in to comment.