Skip to contentSkip to conversation

xdp: xdp_mem_allocator can be NULL in trace_mem_connect().

PATCH Applied Sebastian Andrzej Siewior 2 participants 2 messages Mar 9, 2022 – Mar 11, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 xdp: xdp_mem_allocator can be NULL in trace_mem_connect().

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.

The trace points (mem_connect + mem_disconnect) were put in place to pair connect/disconnect using the IDs. The ID is only assigned if __xdp_reg_mem_model() does not return NULL. That connect trace point is of no use if there is no ID.

Skip that connect trace point if xdp_alloc is NULL.

[ Toke Høiland-Jørgensen delivered the reasoning for skipping the trace
point ]

Fixes 4a48ef70b93b8 ("xdp: Allow registering memory model without rxq reference")

---
v2…v3:
- Use trace_mem_connect_enabled() as suggested by Steven Rostedt.

v1…v2:
- Instead letting the trace point deal with a NULL pointer, skip the trace point.

 net/core/xdp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/xdp.c +2 -1
index 7aba355049862..73fae16264e10 100644
@@ -357,7 +357,8 @@ int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
 	if (IS_ERR(xdp_alloc))
 		return PTR_ERR(xdp_alloc);
 
-	trace_mem_connect(xdp_alloc, xdp_rxq);
+	if (trace_mem_connect_enabled() && xdp_alloc)
+		trace_mem_connect(xdp_alloc, xdp_rxq);
 	return 0;
 }
 
Signature · 1 line
2.35.1
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 9 Mar 2022 23:13:45 +0100 you wrote:

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.

The trace points (mem_connect + mem_disconnect) were put in place to pair connect/disconnect using the IDs. The ID is only assigned if __xdp_reg_mem_model() does not return NULL. That connect trace point is of no use if there is no ID.

[...]

Here is the summary with links:
- [net,v3] xdp: xdp_mem_allocator can be NULL in trace_mem_connect().

    https://git.kernel.org/netdev/net/c/e0ae713023a9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html