From: Jianbo Liu Date: Tue, 20 Feb 2024 08:59:28 +0000 (+0000) Subject: net/sched: flower: Add lock protection when remove filter handle X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1fde0ca3a0de7e9f917668941156959dd5e9108b;p=linux.git net/sched: flower: Add lock protection when remove filter handle As IDR can't protect itself from the concurrent modification, place idr_remove() under the protection of tp->lock. Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier") Signed-off-by: Jianbo Liu Reviewed-by: Cosmin Ratiu Reviewed-by: Gal Pressman Reviewed-by: Jiri Pirko Acked-by: Jamal Hadi Salim Link: https://lore.kernel.org/r/20240220085928.9161-1-jianbol@nvidia.com Signed-off-by: Jakub Kicinski --- diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index efb9d2811b73d..6ee7064c82fcc 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -2460,8 +2460,11 @@ unbind_filter: } errout_idr: - if (!fold) + if (!fold) { + spin_lock(&tp->lock); idr_remove(&head->handle_idr, fnew->handle); + spin_unlock(&tp->lock); + } __fl_put(fnew); errout_tb: kfree(tb);