From patchwork Thu Mar 3 12:26:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Sewior X-Patchwork-Id: 12767410 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 54457C433F5 for ; Thu, 3 Mar 2022 12:27:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233264AbiCCM1r (ORCPT ); Thu, 3 Mar 2022 07:27:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233320AbiCCM1q (ORCPT ); Thu, 3 Mar 2022 07:27:46 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F158217AEF9; Thu, 3 Mar 2022 04:26:50 -0800 (PST) Date: Thu, 3 Mar 2022 13:26:47 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1646310408; 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; bh=/2IrixGajLDVd5J8HzrF+LuMsZqItBwpaII0wZuPf8g=; b=CjB1y8PCdfXh5XLxDXAE2ildunQp6SghTDP8O9tYIHFCOkYoJ2Y5kXADTiEdTRd2amMzva 4674c866t36n76+1yskgcVWflIEeIh51Jky7f9MMyJm2RrOU8RXD+g5fTDJWJs4B+8clTO wJX1b6VYSuoPAvvZ4cUaKfm+PpMWaoXmsvZeT/kpxtTF1DWnasOvT8lvxdfNO8JrnwKPeu ojDoS8IYnp6kOuXZDm9KxOYQovZmaosYZB5H8K4zSNAm3rHV3fTp+wsFHPusJVe0C9bnLu KESwxv3NjydfkqH9dgkEBjWXcy8VZsMkJdBgHWY4zs18AFAxJ12B6Spa5bbfKA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1646310408; 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; bh=/2IrixGajLDVd5J8HzrF+LuMsZqItBwpaII0wZuPf8g=; b=uCw+2UiyriU1hW8trcV7w3cEA6PHbBnwy19dFZPHZB0QqED0l9HEMEmiJslxPYfeRUNOAE CEdZ/qIxkYyGRFBQ== From: Sebastian Andrzej Siewior To: netdev@vger.kernel.org, bpf@vger.kernel.org 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 =?utf-8?q?H=C3=B8iland-J=C3=B8rgensen?= , Yonghong Song Subject: [PATCH net] 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. 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 --- 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; ),