[SRU][J:linux-bluefield][PATCH v4 07/10] net/sched: flower: fix error handler on replace
William Tu
witu at nvidia.com
Mon Jun 19 17:49:38 UTC 2023
From: Vlad Buslov <vladbu at nvidia.com>
BugLink: https://bugs.launchpad.net/bugs/2012571
When replacing a filter (i.e. 'fold' pointer is not NULL) the insertion of
new filter to idr is postponed until later in code since handle is already
provided by the user. However, the error handling code in fl_change()
always assumes that the new filter had been inserted into idr. If error
handler is reached when replacing existing filter it may remove it from idr
therefore making it unreachable for delete or dump afterwards. Fix the
issue by verifying that 'fold' argument wasn't provided by caller before
calling idr_remove().
Fixes: 08a0063df3ae ("net/sched: flower: Move filter handle initialization earlier")
(backported from commit fd741f0d9f702c193b2b44225c004f8c5d5be163)
[witu: manually fix the idr_remove line]
Signed-off-by: William Tu <witu at nvidia.com>
Signed-off-by: Vlad Buslov <vladbu at nvidia.com>
Reviewed-by: Pedro Tammela <pctammela at mojatatu.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
Signed-off-by: William Tu <witu at nvidia.com>
---
net/sched/cls_flower.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 71ffd558a5f2..33b1eeccc21b 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -2183,7 +2183,9 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
errout_mask:
fl_mask_put(head, fnew->mask);
errout_idr:
- idr_remove(&head->handle_idr, fnew->handle);
+ if (!fold)
+ idr_remove(&head->handle_idr, fnew->handle);
+errout:
__fl_put(fnew);
errout_tb:
kfree(tb);
--
2.34.1
More information about the kernel-team
mailing list