* [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer()
@ 2026-06-13 10:14 NeKon69
2026-06-15 12:08 ` Simon Horman
2026-06-16 8:27 ` [Intel-wired-lan] " Kwapulinski, Piotr
0 siblings, 2 replies; 3+ messages in thread
From: NeKon69 @ 2026-06-13 10:14 UTC (permalink / raw)
To: anthony.l.nguyen, przemyslaw.kitszel
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, victor.raj,
intel-wired-lan, netdev, linux-kernel, NeKon69
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 <nobodqwe@gmail.com>
---
drivers/net/ethernet/intel/ice/ice_sched.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
index fff0c1afdb41..089ad3967be5 100644
--- a/drivers/net/ethernet/intel/ice/ice_sched.c
+++ b/drivers/net/ethernet/intel/ice/ice_sched.c
@@ -1074,11 +1074,11 @@ ice_sched_add_nodes_to_layer(struct ice_port_info *pi,
u32 *first_teid_ptr = first_node_teid;
u16 new_num_nodes = num_nodes;
int status = 0;
+ u32 temp;
*num_nodes_added = 0;
while (*num_nodes_added < num_nodes) {
u16 max_child_nodes, num_added = 0;
- u32 temp;
status = ice_sched_add_nodes_to_hw_layer(pi, tc_node, parent,
layer, new_num_nodes,
--
2.54.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer()
2026-06-13 10:14 [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer() NeKon69
@ 2026-06-15 12:08 ` Simon Horman
2026-06-16 8:27 ` [Intel-wired-lan] " Kwapulinski, Piotr
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-06-15 12:08 UTC (permalink / raw)
To: NeKon69
Cc: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
edumazet, kuba, pabeni, victor.raj, intel-wired-lan, netdev,
linux-kernel
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 <nobodqwe@gmail.com>
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()
...
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [Intel-wired-lan] [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer()
2026-06-13 10:14 [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer() NeKon69
2026-06-15 12:08 ` Simon Horman
@ 2026-06-16 8:27 ` Kwapulinski, Piotr
1 sibling, 0 replies; 3+ messages in thread
From: Kwapulinski, Piotr @ 2026-06-16 8:27 UTC (permalink / raw)
To: NeKon69, Nguyen, Anthony L, Kitszel, Przemyslaw
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, victor.raj,
intel-wired-lan, netdev, linux-kernel
>-----Original Message-----
>From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of NeKon69
>Sent: Saturday, June 13, 2026 12:15 PM
>To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>
>Cc: 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; NeKon69 <nobodqwe@gmail.com>
>Subject: [Intel-wired-lan] [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer()
>
>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 <nobodqwe@gmail.com>
>---
> drivers/net/ethernet/intel/ice/ice_sched.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
>index fff0c1afdb41..089ad3967be5 100644
>--- a/drivers/net/ethernet/intel/ice/ice_sched.c
>+++ b/drivers/net/ethernet/intel/ice/ice_sched.c
>@@ -1074,11 +1074,11 @@ ice_sched_add_nodes_to_layer(struct ice_port_info *pi,
> u32 *first_teid_ptr = first_node_teid;
> u16 new_num_nodes = num_nodes;
> int status = 0;
>+ u32 temp;
>
> *num_nodes_added = 0;
> while (*num_nodes_added < num_nodes) {
> u16 max_child_nodes, num_added = 0;
>- u32 temp;
>
> status = ice_sched_add_nodes_to_hw_layer(pi, tc_node, parent,
> layer, new_num_nodes,
>--
>2.54.0
>
Reviewed-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-16 8:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-13 10:14 [PATCH net] ice: Fix use-after-scope in ice_sched_add_nodes_to_layer() NeKon69
2026-06-15 12:08 ` Simon Horman
2026-06-16 8:27 ` [Intel-wired-lan] " Kwapulinski, Piotr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome