public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier
@ 2025-06-14  0:54 Hyunwoo Kim
  2025-06-17 17:03 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hyunwoo Kim @ 2025-06-14  0:54 UTC (permalink / raw)
  To: vinicius.gomes, jhs, xiyou.wangcong, jiri, davem, edumazet, kuba,
	pabeni, horms, vladimir.oltean
  Cc: netdev, imv4bel, v4bel

Since taprio’s taprio_dev_notifier() isn’t protected by an
RCU read-side critical section, a race with advance_sched()
can lead to a use-after-free.

Adding rcu_read_lock() inside taprio_dev_notifier() prevents this.

Fixes: fed87cc6718a ("net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
---
Changes in v3:
- Change so that taprio_set_picos_per_byte() is not included in the lock.
- v2: https://lore.kernel.org/all/aEq3J4ODxH7x+neT@v4bel-B760M-AORUS-ELITE-AX/

Changes in v2:
- Add the appropriate tags.
- v1: https://lore.kernel.org/all/aElUZyKy7x66X3SD@v4bel-B760M-AORUS-ELITE-AX/
---
 net/sched/sch_taprio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 14021b812329..2b14c81a87e5 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1328,13 +1328,15 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
 
 		stab = rtnl_dereference(q->root->stab);
 
-		oper = rtnl_dereference(q->oper_sched);
+		rcu_read_lock();
+		oper = rcu_dereference(q->oper_sched);
 		if (oper)
 			taprio_update_queue_max_sdu(q, oper, stab);
 
-		admin = rtnl_dereference(q->admin_sched);
+		admin = rcu_dereference(q->admin_sched);
 		if (admin)
 			taprio_update_queue_max_sdu(q, admin, stab);
+		rcu_read_unlock();
 
 		break;
 	}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier
  2025-06-14  0:54 [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier Hyunwoo Kim
@ 2025-06-17 17:03 ` Simon Horman
  2025-06-17 17:35 ` Eric Dumazet
  2025-06-17 23:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-06-17 17:03 UTC (permalink / raw)
  To: Hyunwoo Kim
  Cc: vinicius.gomes, jhs, xiyou.wangcong, jiri, davem, edumazet, kuba,
	pabeni, vladimir.oltean, netdev, v4bel

On Fri, Jun 13, 2025 at 08:54:57PM -0400, Hyunwoo Kim wrote:
> Since taprio’s taprio_dev_notifier() isn’t protected by an
> RCU read-side critical section, a race with advance_sched()
> can lead to a use-after-free.
> 
> Adding rcu_read_lock() inside taprio_dev_notifier() prevents this.
> 
> Fixes: fed87cc6718a ("net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
> ---
> Changes in v3:
> - Change so that taprio_set_picos_per_byte() is not included in the lock.
> - v2: https://lore.kernel.org/all/aEq3J4ODxH7x+neT@v4bel-B760M-AORUS-ELITE-AX/
> 
> Changes in v2:
> - Add the appropriate tags.
> - v1: https://lore.kernel.org/all/aElUZyKy7x66X3SD@v4bel-B760M-AORUS-ELITE-AX/

Thanks for the update.

I agree that this is consistent with the review by Vladimir of v2.

Reviewed-by: Simon Horman <horms@kernel.org>

...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier
  2025-06-14  0:54 [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier Hyunwoo Kim
  2025-06-17 17:03 ` Simon Horman
@ 2025-06-17 17:35 ` Eric Dumazet
  2025-06-17 23:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-06-17 17:35 UTC (permalink / raw)
  To: Hyunwoo Kim
  Cc: vinicius.gomes, jhs, xiyou.wangcong, jiri, davem, kuba, pabeni,
	horms, vladimir.oltean, netdev, v4bel

On Fri, Jun 13, 2025 at 5:55 PM Hyunwoo Kim <imv4bel@gmail.com> wrote:
>
> Since taprio’s taprio_dev_notifier() isn’t protected by an
> RCU read-side critical section, a race with advance_sched()
> can lead to a use-after-free.
>
> Adding rcu_read_lock() inside taprio_dev_notifier() prevents this.
>
> Fixes: fed87cc6718a ("net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
> ---

Reviewed-by: Eric Dumazet <edumazet@google.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier
  2025-06-14  0:54 [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier Hyunwoo Kim
  2025-06-17 17:03 ` Simon Horman
  2025-06-17 17:35 ` Eric Dumazet
@ 2025-06-17 23:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-17 23:30 UTC (permalink / raw)
  To: Hyunwoo Kim
  Cc: vinicius.gomes, jhs, xiyou.wangcong, jiri, davem, edumazet, kuba,
	pabeni, horms, vladimir.oltean, netdev, v4bel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 13 Jun 2025 20:54:57 -0400 you wrote:
> Since taprio’s taprio_dev_notifier() isn’t protected by an
> RCU read-side critical section, a race with advance_sched()
> can lead to a use-after-free.
> 
> Adding rcu_read_lock() inside taprio_dev_notifier() prevents this.
> 
> Fixes: fed87cc6718a ("net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
> 
> [...]

Here is the summary with links:
  - [v3] net/sched: fix use-after-free in taprio_dev_notifier
    https://git.kernel.org/netdev/net/c/b160766e26d4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-17 23:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-14  0:54 [PATCH v3] net/sched: fix use-after-free in taprio_dev_notifier Hyunwoo Kim
2025-06-17 17:03 ` Simon Horman
2025-06-17 17:35 ` Eric Dumazet
2025-06-17 23:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox