Skip to content

Commit b6663ad

Browse files
committed
Merge branch 'cls_bpf'
Daniel Borkmann says: ==================== Two cls_bpf fixes Found them while doing a review on act_bpf and going over the cls_bpf code again. Will also address the first issue in act_bpf as it needs to be fixed there, too. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9e79ce6 + 3f2ab13 commit b6663ad

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

net/sched/cls_bpf.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
180180
}
181181

182182
bpf_size = bpf_len * sizeof(*bpf_ops);
183+
if (bpf_size != nla_len(tb[TCA_BPF_OPS])) {
184+
ret = -EINVAL;
185+
goto errout;
186+
}
187+
183188
bpf_ops = kzalloc(bpf_size, GFP_KERNEL);
184189
if (bpf_ops == NULL) {
185190
ret = -ENOMEM;
@@ -215,15 +220,21 @@ static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,
215220
struct cls_bpf_head *head)
216221
{
217222
unsigned int i = 0x80000000;
223+
u32 handle;
218224

219225
do {
220226
if (++head->hgen == 0x7FFFFFFF)
221227
head->hgen = 1;
222228
} while (--i > 0 && cls_bpf_get(tp, head->hgen));
223-
if (i == 0)
229+
230+
if (unlikely(i == 0)) {
224231
pr_err("Insufficient number of handles\n");
232+
handle = 0;
233+
} else {
234+
handle = head->hgen;
235+
}
225236

226-
return i;
237+
return handle;
227238
}
228239

229240
static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,

0 commit comments

Comments
 (0)