Skip to content

Commit

Permalink
net: sched: act_ipt: remove dependency on rtnl lock
Browse files Browse the repository at this point in the history
Use tcf spinlock to protect ipt action private data from concurrent
modification during dump. Ipt init already takes tcf spinlock when
modifying ipt state.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vlad Buslov authored and David S. Miller committed Aug 11, 2018
1 parent 54d0d42 commit ff25276
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/sched/act_ipt.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind,
* for foolproof you need to not assume this
*/

spin_lock_bh(&ipt->tcf_lock);
t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC);
if (unlikely(!t))
goto nla_put_failure;
Expand All @@ -307,10 +308,12 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind,
if (nla_put_64bit(skb, TCA_IPT_TM, sizeof(tm), &tm, TCA_IPT_PAD))
goto nla_put_failure;

spin_unlock_bh(&ipt->tcf_lock);
kfree(t);
return skb->len;

nla_put_failure:
spin_unlock_bh(&ipt->tcf_lock);
nlmsg_trim(skb, b);
kfree(t);
return -1;
Expand Down

0 comments on commit ff25276

Please sign in to comment.