]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/sched: flower: fix error handler on replace
authorVlad Buslov <vladbu@nvidia.com>
Thu, 4 May 2023 18:16:16 +0000 (20:16 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 5 May 2023 09:01:31 +0000 (10:01 +0100)
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")
Signed-off-by: Vlad Buslov <vladbu@nvidia.com>
Reviewed-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_flower.c

index ac4f344c52e04204cae803b1b704a33c95c61e42..9dbc43388e579590dc4e2faccae5eb62144c1696 100644 (file)
@@ -2339,7 +2339,8 @@ errout_hw:
 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);
        __fl_put(fnew);
 errout_tb:
        kfree(tb);