Skip to content

Commit 506a03a

Browse files
congwangdavem330
authored andcommitted
net_sched: add missing tcf_lock for act_connmark
According to the new locking rule, we have to take tcf_lock for both ->init() and ->dump(), as RTNL will be removed. However, it is missing for act_connmark. Cc: Vlad Buslov <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aa4e689 commit 506a03a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

net/sched/act_connmark.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla,
143143
return -EEXIST;
144144
}
145145
/* replacing action and zone */
146+
spin_lock_bh(&ci->tcf_lock);
146147
ci->tcf_action = parm->action;
147148
ci->zone = parm->zone;
149+
spin_unlock_bh(&ci->tcf_lock);
148150
ret = 0;
149151
}
150152

@@ -156,26 +158,29 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,
156158
{
157159
unsigned char *b = skb_tail_pointer(skb);
158160
struct tcf_connmark_info *ci = to_connmark(a);
159-
160161
struct tc_connmark opt = {
161162
.index = ci->tcf_index,
162163
.refcnt = refcount_read(&ci->tcf_refcnt) - ref,
163164
.bindcnt = atomic_read(&ci->tcf_bindcnt) - bind,
164-
.action = ci->tcf_action,
165-
.zone = ci->zone,
166165
};
167166
struct tcf_t t;
168167

168+
spin_lock_bh(&ci->tcf_lock);
169+
opt.action = ci->tcf_action;
170+
opt.zone = ci->zone;
169171
if (nla_put(skb, TCA_CONNMARK_PARMS, sizeof(opt), &opt))
170172
goto nla_put_failure;
171173

172174
tcf_tm_dump(&t, &ci->tcf_tm);
173175
if (nla_put_64bit(skb, TCA_CONNMARK_TM, sizeof(t), &t,
174176
TCA_CONNMARK_PAD))
175177
goto nla_put_failure;
178+
spin_unlock_bh(&ci->tcf_lock);
176179

177180
return skb->len;
181+
178182
nla_put_failure:
183+
spin_unlock_bh(&ci->tcf_lock);
179184
nlmsg_trim(skb, b);
180185
return -1;
181186
}

0 commit comments

Comments
 (0)