Commit fd741f0d authored by Vlad Buslov's avatar Vlad Buslov Committed by David S. Miller

net/sched: flower: fix error handler on replace

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: 08a0063d ("net/sched: flower: Move filter handle initialization earlier")
Signed-off-by: default avatarVlad Buslov <vladbu@nvidia.com>
Reviewed-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5110f3ff
...@@ -2339,6 +2339,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, ...@@ -2339,6 +2339,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
errout_mask: errout_mask:
fl_mask_put(head, fnew->mask); fl_mask_put(head, fnew->mask);
errout_idr: errout_idr:
if (!fold)
idr_remove(&head->handle_idr, fnew->handle); idr_remove(&head->handle_idr, fnew->handle);
__fl_put(fnew); __fl_put(fnew);
errout_tb: errout_tb:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment