]> git.baikalelectronics.ru Git - kernel.git/commit
net: sock: tracing: Fix sock_exceed_buf_limit not to dereference stale pointer
authorSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 6 Jul 2022 14:50:40 +0000 (10:50 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Jul 2022 11:06:17 +0000 (12:06 +0100)
commit8dd7e882fcb72334e79119e3c45a42676882911f
treefc92b0a72abf658bddb12effe5d13f9c5cf95361
parentc685951362c89e3ae74192e88c6ab9156a5bdd0d
net: sock: tracing: Fix sock_exceed_buf_limit not to dereference stale pointer

The trace event sock_exceed_buf_limit saves the prot->sysctl_mem pointer
and then dereferences it in the TP_printk() portion. This is unsafe as the
TP_printk() portion is executed at the time the buffer is read. That is,
it can be seconds, minutes, days, months, even years later. If the proto
is freed, then this dereference will can also lead to a kernel crash.

Instead, save the sysctl_mem array into the ring buffer and have the
TP_printk() reference that instead. This is the proper and safe way to
read pointers in trace events.

Link: https://lore.kernel.org/all/20220706052130.16368-12-kuniyu@amazon.com/
Cc: stable@vger.kernel.org
Fixes: 51ca1365c5b6f ("core: add tracepoints for queueing skb to rcvbuf")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/trace/events/sock.h