From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22D19CD98C7 for ; Mon, 15 Jun 2026 12:08:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E473B60707; Mon, 15 Jun 2026 12:08:09 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id HHxRGHkRxdbj; Mon, 15 Jun 2026 12:08:09 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 426F06060A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1781525289; bh=1mUZryqNrhJrA6yQ4bjuj9ZOB5+Z2b6bKF1iLQiqQNU=; h=Date:From:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iYLG4bvFpv6Z/DzXCycVc+4NVLiXiJBL5xeSOUrOgCqrFYeZFki5l0kpk835QiOHx DOsF0bIfoPd8BKZpnib0fqZ4dHJ2bSwYOygNkv5SV487xcg/uHO8ImqJglgegFRS8p M1brdvQDf/HVKewqndanCYW6kQszVCl41zphaOqGVgTA8vZihF00ZpAWk2bQtLVIJ4 KZyEQpZIgrtA/lXV1Sz6E0QSVLI9uw/rJdYZjLa9nfCXgKp+aTkQy8nEA/fL8CoQqB B9qUJyqCGYDal8Q4uG3m6fmyWXpgSMEOvLcAkHxMnDw3bUBw8+Z4Dc7Ylx3I1hlTzP GJ57kxLLgWAfQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id 426F06060A; Mon, 15 Jun 2026 12:08:09 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists1.osuosl.org (Postfix) with ESMTP id D76BADE for ; Mon, 15 Jun 2026 12:08:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C961540F76 for ; Mon, 15 Jun 2026 12:08:07 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 3j9BCembL1Kc for ; Mon, 15 Jun 2026 12:08:07 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2600:3c04:e001:324:0:1991:8:25; helo=tor.source.kernel.org; envelope-from=horms@kernel.org; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 09AF040F75 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 09AF040F75 Received: from tor.source.kernel.org (tor.source.kernel.org [IPv6:2600:3c04:e001:324:0:1991:8:25]) by smtp4.osuosl.org (Postfix) with ESMTPS id 09AF040F75 for ; Mon, 15 Jun 2026 12:08:06 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 59D326008A; Mon, 15 Jun 2026 12:08:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C99CE1F000E9; Mon, 15 Jun 2026 12:08:02 +0000 (UTC) Date: Mon, 15 Jun 2026 13:08:00 +0100 From: Simon Horman To: NeKon69 Cc: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, victor.raj@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <20260615120800.GA757061@horms.kernel.org> References: <20260613101440.80190-1-nobodqwe@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260613101440.80190-1-nobodqwe@gmail.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781525285; bh=1mUZryqNrhJrA6yQ4bjuj9ZOB5+Z2b6bKF1iLQiqQNU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=kQXezVeJNQk6hi5xqqY6qBFU65wqDpm30pzdgat1bSKqOY92y7k7+Bh+tRw1q7L7B bo5snRmcH2/hh9XvUoWy892UwX2dZpH2J/gs+CnR2p//o89OhOCnPkX/5DnHb9xqGm WwYDAxjvdzuPe5yc0dELhQUqdZYlTw4UYOPBgek6YiHSpWZtECfJN/EcjR1mspo47W lpJbGGkEi2SqifD/UEK35M9cXiS50Yxudsu4anYl7u0KmmoqVSoxS1oWTBk7QIeLfM hibpMwkhNNPJoC5mOTMHB8J/2HgVKRX/JiUeJrJBjcRPjuKkjqXRmP2EkNefMOYpb/ S9eAaQqZkyLnA== X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Mailman-Original-Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kQXezVeJ Subject: Re: [Intel-wired-lan] [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Sat, Jun 13, 2026 at 01:14:40PM +0300, NeKon69 wrote: > Commit 7fb09a737536 ("ice: Modify recursive way of adding nodes") > changed ice_sched_add_nodes_to_layer() from recursive control flow to an > iterative loop. > > Inside the loop, first_teid_ptr may be set to the address of a > block-local variable: > > u32 temp; > ... > if (num_added) > first_teid_ptr = &temp; > > On the next loop iteration, first_teid_ptr may be passed to > ice_sched_add_nodes_to_hw_layer(), after temp from the previous > iteration has gone out of scope. > > Move temp outside the loop so the pointer remains valid for the lifetime > of ice_sched_add_nodes_to_layer(). > > This was found by Clang with LifetimeSafety enabled while testing C > language support on a Linux allmodconfig build. > > Fixes: 7fb09a737536 ("ice: Modify recursive way of adding nodes") > Link: https://github.com/llvm/llvm-project/pull/203270 > Signed-off-by: NeKon69 I agree that this patch is correct. However, I do wonder if it would be cleaner to allow passing NULL as the first_node_teid argument of ice_sched_add_nodes_to_hw_layer() ... From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BC82379C33; Mon, 15 Jun 2026 12:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781525286; cv=none; b=FtQU3FRTAtIgLHKfEkZ1IwpFYIzsx3wabQWP+8KuoyJ1tyyguQqmk1C7+3xRqbuAemzuoJ/MZWJa+PXZxEVkV7sX12K72Q4MJJYbrvlOFLr4yXSkvRrELzfQk+IxJy3WFzBULfT3FzQ06DDoFToLQ4Y9D/GJEN1n22gVc5/gDlU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781525286; c=relaxed/simple; bh=CwJUj6I5kPJ/A7PWvRHQcW6DKhG8kGLWzT1dGwVTm6E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KHwA/FzqrwWrc2jeS9ZQEtvtrW9SgUUCW7XZCiVynfapY0S59IYx4F2koK6tkCLchrkSriT4wyLF1wcXQcQHby017B/6zB4sbKLsyiDP9KUa4FbylCsfqvrfmLtoVM/jq04GqmM4MBxaLFwVediWjoxVUIchJfZc/BAg1kcEWB0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kQXezVeJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kQXezVeJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C99CE1F000E9; Mon, 15 Jun 2026 12:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781525285; bh=1mUZryqNrhJrA6yQ4bjuj9ZOB5+Z2b6bKF1iLQiqQNU=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=kQXezVeJNQk6hi5xqqY6qBFU65wqDpm30pzdgat1bSKqOY92y7k7+Bh+tRw1q7L7B bo5snRmcH2/hh9XvUoWy892UwX2dZpH2J/gs+CnR2p//o89OhOCnPkX/5DnHb9xqGm WwYDAxjvdzuPe5yc0dELhQUqdZYlTw4UYOPBgek6YiHSpWZtECfJN/EcjR1mspo47W lpJbGGkEi2SqifD/UEK35M9cXiS50Yxudsu4anYl7u0KmmoqVSoxS1oWTBk7QIeLfM hibpMwkhNNPJoC5mOTMHB8J/2HgVKRX/JiUeJrJBjcRPjuKkjqXRmP2EkNefMOYpb/ S9eAaQqZkyLnA== Date: Mon, 15 Jun 2026 13:08:00 +0100 From: Simon Horman To: NeKon69 Cc: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, victor.raj@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer() Message-ID: <20260615120800.GA757061@horms.kernel.org> References: <20260613101440.80190-1-nobodqwe@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260613101440.80190-1-nobodqwe@gmail.com> On Sat, Jun 13, 2026 at 01:14:40PM +0300, NeKon69 wrote: > Commit 7fb09a737536 ("ice: Modify recursive way of adding nodes") > changed ice_sched_add_nodes_to_layer() from recursive control flow to an > iterative loop. > > Inside the loop, first_teid_ptr may be set to the address of a > block-local variable: > > u32 temp; > ... > if (num_added) > first_teid_ptr = &temp; > > On the next loop iteration, first_teid_ptr may be passed to > ice_sched_add_nodes_to_hw_layer(), after temp from the previous > iteration has gone out of scope. > > Move temp outside the loop so the pointer remains valid for the lifetime > of ice_sched_add_nodes_to_layer(). > > This was found by Clang with LifetimeSafety enabled while testing C > language support on a Linux allmodconfig build. > > Fixes: 7fb09a737536 ("ice: Modify recursive way of adding nodes") > Link: https://github.com/llvm/llvm-project/pull/203270 > Signed-off-by: NeKon69 I agree that this patch is correct. However, I do wonder if it would be cleaner to allow passing NULL as the first_node_teid argument of ice_sched_add_nodes_to_hw_layer() ...