Skip to content

Commit f9fda67

Browse files
V4belsmb49
authored andcommitted
net/sched: fix use-after-free in taprio_dev_notifier
BugLink: https://bugs.launchpad.net/bugs/2120812 commit b160766e26d4e2e2d6fe2294e0b02f92baefcec5 upstream. 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: fed87cc ("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: Simon Horman <horms@kernel.org> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/aEzIYYxt0is9upYG@v4bel-B760M-AORUS-ELITE-AX Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 5e5a9a7 commit f9fda67

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/sched/sch_taprio.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,13 +1328,15 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
13281328

13291329
stab = rtnl_dereference(q->root->stab);
13301330

1331-
oper = rtnl_dereference(q->oper_sched);
1331+
rcu_read_lock();
1332+
oper = rcu_dereference(q->oper_sched);
13321333
if (oper)
13331334
taprio_update_queue_max_sdu(q, oper, stab);
13341335

1335-
admin = rtnl_dereference(q->admin_sched);
1336+
admin = rcu_dereference(q->admin_sched);
13361337
if (admin)
13371338
taprio_update_queue_max_sdu(q, admin, stab);
1339+
rcu_read_unlock();
13381340

13391341
break;
13401342
}

0 commit comments

Comments
 (0)