Skip to content

Commit b160766

Browse files
V4belkuba-moo
authored andcommitted
net/sched: fix use-after-free in taprio_dev_notifier
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: [email protected] Signed-off-by: Hyunwoo Kim <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/aEzIYYxt0is9upYG@v4bel-B760M-AORUS-ELITE-AX Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4300fd6 commit b160766

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)