All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] xdp: xdp_mem_allocator can be NULL in trace_mem_connect().
@ 2022-03-03 12:26 Sebastian Andrzej Siewior
  2022-03-03 13:59 ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 10+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-03-03 12:26 UTC (permalink / raw)
  To: netdev, bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	David S. Miller, Ingo Molnar, Jakub Kicinski,
	Jesper Dangaard Brouer, John Fastabend, KP Singh,
	Martin KaFai Lau, Song Liu, Steven Rostedt, Thomas Gleixner,
	Toke Høiland-Jørgensen, Yonghong Song

Since the commit mentioned below __xdp_reg_mem_model() can return a NULL
pointer. This pointer is dereferenced in trace_mem_connect() which leads
to segfault. It can be reproduced with enabled trace events during ifup.

Only assign the arguments in the trace-event macro if `xa' is set.
Otherwise set the parameters to 0.

Fixes: 4a48ef70b93b8 ("xdp: Allow registering memory model without rxq reference")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/trace/events/xdp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/trace/events/xdp.h b/include/trace/events/xdp.h
index c40fc97f94171..9196dcd08e6c7 100644
--- a/include/trace/events/xdp.h
+++ b/include/trace/events/xdp.h
@@ -362,9 +362,9 @@ TRACE_EVENT(mem_connect,
 
 	TP_fast_assign(
 		__entry->xa		= xa;
-		__entry->mem_id		= xa->mem.id;
-		__entry->mem_type	= xa->mem.type;
-		__entry->allocator	= xa->allocator;
+		__entry->mem_id		= xa ? xa->mem.id : 0;
+		__entry->mem_type	= xa ? xa->mem.type : 0;
+		__entry->allocator	= xa ? xa->allocator : NULL;
 		__entry->rxq		= rxq;
 		__entry->ifindex	= rxq->dev->ifindex;
 	),
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-03-09 21:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 12:26 [PATCH net] xdp: xdp_mem_allocator can be NULL in trace_mem_connect() Sebastian Andrzej Siewior
2022-03-03 13:59 ` Toke Høiland-Jørgensen
2022-03-03 14:12   ` Sebastian Andrzej Siewior
2022-03-03 17:31     ` Jesper Dangaard Brouer
2022-03-07 16:50     ` Toke Høiland-Jørgensen
2022-03-07 17:59       ` Sebastian Andrzej Siewior
2022-03-07 18:07         ` Toke Høiland-Jørgensen
2022-03-09 17:15           ` Jakub Kicinski
2022-03-09 20:48             ` Sebastian Andrzej Siewior
2022-03-09 21:03               ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.