From patchwork Wed Mar 9 22:13:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12775659 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4E21C433FE for ; Wed, 9 Mar 2022 22:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236315AbiCIWOx (ORCPT ); Wed, 9 Mar 2022 17:14:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232513AbiCIWOw (ORCPT ); Wed, 9 Mar 2022 17:14:52 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3B854A3CB; Wed, 9 Mar 2022 14:13:49 -0800 (PST) Date: Wed, 9 Mar 2022 23:13:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1646864027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6L0rg3bdg9PSfTr778oNR9IkfA6VNn058COlVBv40UE=; b=VIsD/1IRo06lRVr6Gh5UZWT2Ko9YVNYI025lqTRUjC/X3/b3KNjYT4BkjiAS7aMpaIOFeA zX4K0q2jAn+nZZ+e2DWZ9/fcMv4e99SMfu9FhBLkk/oxN70RF+v6vMg5z7iq02cWTVKip4 FpcfVr6TpdV6G2J3YmdGYCbUq5dPFE4p+iztM8EhF4H1wl+WsY4RNqc8Z/CUv+fKQAogIa SF0tfBC127rIaqQRsSs//zHBCvN4AUc0SrXuzXrcydhsmDVrjOHiIePRdpvmMq7Qfu1+Gd MbIF+NmlfzBJBsfUq6VtqG724DdXx92CafdGj3wvvqtEv11zI8ztjmfSMjRGpQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1646864027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6L0rg3bdg9PSfTr778oNR9IkfA6VNn058COlVBv40UE=; b=TVh3BqYrL8c8UZawotF0e8QFGl2v7NiqAzF2xTno3fIjHYkcIFtewAVbQqMPvXZm17Z877 ovQv3BgpIu5ztWBA== From: Sebastian Andrzej Siewior To: Jakub Kicinski Cc: Toke =?utf-8?q?H=C3=B8iland-J=C3=B8rgensen?= , netdev@vger.kernel.org, bpf@vger.kernel.org, Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , "David S. Miller" , Ingo Molnar , Jesper Dangaard Brouer , John Fastabend , KP Singh , Martin KaFai Lau , Song Liu , Steven Rostedt , Thomas Gleixner , Yonghong Song Subject: [PATCH net v3] xdp: xdp_mem_allocator can be NULL in trace_mem_connect(). Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 Acked-by: Toke Høiland-Jørgensen --- 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(-) diff --git a/net/core/xdp.c b/net/core/xdp.c index 7aba355049862..73fae16264e10 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -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; }