Skip to contentSkip to conversation

Minor cls_basic, act_bpf update

PATCH In review Daniel Borkmann 4 participants 6 messages Jan 22, 2015 – Jan 27, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Minor cls_basic, act_bpf update

Daniel Borkmann (2):
net: cls_basic: return from walking on match in basic_get
net: act_bpf: fix size mismatch on filter preparation

 net/sched/act_bpf.c   | 3 +++
 net/sched/cls_basic.c | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.11.7
#3 lore raw

PATCH 2/2 net: act_bpf: fix size mismatch on filter preparation

Similarly as in cls_bpf, also this code needs to reject mismatches.

Reference: http://article.gmane.org/gmane.linux.network/347406

Fixes d23b8ad8ab23 ("tc: add BPF based action")
---
 net/sched/act_bpf.c | 3 +++
 1 file changed, 3 insertions(+)
net/sched/act_bpf.c +3 -0
index 1bd257e..82c5d7f 100644
@@ -122,6 +122,9 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla,
 		return -EINVAL;
 
 	bpf_size = bpf_num_ops * sizeof(*bpf_ops);
+	if (bpf_size != nla_len(tb[TCA_ACT_BPF_OPS]))
+		return -EINVAL;
+
 	bpf_ops = kzalloc(bpf_size, GFP_KERNEL);
 	if (!bpf_ops)
 		return -ENOMEM;
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/2 net: cls_basic: return from walking on match in basic_get

In reply to Daniel Borkmann

As soon as we've found a matching handle in basic_get(), we can return it. There's no need to continue walking until the end of a filter chain, since they are unique anyway.

---
 net/sched/cls_basic.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/sched/cls_basic.c +5 -2
index 5aed341..fc399db 100644
@@ -65,9 +65,12 @@ static unsigned long basic_get(struct tcf_proto *tp, u32 handle)
 	if (head == NULL)
 		return 0UL;
 
-	list_for_each_entry(f, &head->flist, link)
-		if (f->handle == handle)
+	list_for_each_entry(f, &head->flist, link) {
+		if (f->handle == handle) {
 			l = (unsigned long) f;
+			break;
+		}
+	}
 
 	return l;
 }
Signature · 1 line
1.7.11.7
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH net-next 1/2] net: cls_basic: return from walking on match in basic_get

Quoted 7 lines · Daniel Borkmann

As soon as we've found a matching handle in basic_get(), we can return it. There's no need to continue walking until the end of a filter chain, since they are unique anyway.

Acked-by on v1 2/2
#4 lore raw

Re: [PATCH net-next 2/2] net: act_bpf: fix size mismatch on filter preparation

In reply to Daniel Borkmann
Quoted 6 lines · Daniel Borkmann

Similarly as in cls_bpf, also this code needs to reject mismatches.

Reference: http://article.gmane.org/gmane.linux.network/347406

Fixes d23b8ad8ab23 ("tc: add BPF based action")
maintainer
#5 lore raw
In reply to Daniel Borkmann

From: Daniel Borkmann <[email protected]>
Date: Thu, 22 Jan 2015 10:58:17 +0100

Quoted 3 lines

Daniel Borkmann (2):
net: cls_basic: return from walking on match in basic_get
net: act_bpf: fix size mismatch on filter preparation

Seires applied, thanks.