sch_netem: fix issues in netem_change() vs get_dist_table()
authorEric Dumazet <edumazet@google.com>
Thu, 22 Jun 2023 18:15:03 +0000 (18:15 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 24 Jun 2023 22:12:47 +0000 (15:12 -0700)
commit11b73313c12403f617b47752db0ab3deef201af7
tree01b3c7c76cd895cdc037f5a299930c2556bd2461
parenteb441289f940c86df47db95044820fa5cf90c21f
sch_netem: fix issues in netem_change() vs get_dist_table()

In blamed commit, I missed that get_dist_table() was allocating
memory using GFP_KERNEL, and acquiring qdisc lock to perform
the swap of newly allocated table with current one.

In this patch, get_dist_table() is allocating memory and
copy user data before we acquire the qdisc lock.

Then we perform swap operations while being protected by the lock.

Note that after this patch netem_change() no longer can do partial changes.
If an error is returned, qdisc conf is left unchanged.

Fixes: 2174a08db80d ("sch_netem: acquire qdisc lock in netem_change()")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230622181503.2327695-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/sched/sch_netem.c