This is a note to let you know that I've just added the patch titled xdp: xdp_mem_allocator can be NULL in trace_mem_connect(). to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xdp-xdp_mem_allocator-can-be-null-in-trace_mem_conne.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit da98b03bf70e200143f86b1f18a48fd68368eccc Author: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> Date: Wed Mar 9 23:13:45 2022 +0100 xdp: xdp_mem_allocator can be NULL in trace_mem_connect(). [ Upstream commit e0ae713023a9d09d6e1b454bdc8e8c1dd32c586e ] 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") Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> Acked-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx> Link: https://lore.kernel.org/r/YikmmXsffE+QajTB@xxxxxxxxxxxxx Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/net/core/xdp.c b/net/core/xdp.c index 5ed2e9d5a3191..a3e3d2538a3a8 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -359,7 +359,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; }