[PATCH] net sched: text ematch: zero out ts_state before using it

Subsystems: networking [general], tc subsystem, the rest

STALE4315d

4 messages, 2 authors, 2014-10-09 · open the first message on its own page

[PATCH] net sched: text ematch: zero out ts_state before using it

From: Omar Sandoval <osandov@osandov.com>
Date: 2014-10-09 16:05:59

textsearch_find zeroes out the offset, but the control buffer (which may or may
not matter in this case) needs to be zeroed out as well.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
 net/sched/em_text.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/sched/em_text.c b/net/sched/em_text.c
index 15d353d..2a1b6d9 100644
--- a/net/sched/em_text.c
+++ b/net/sched/em_text.c
@@ -36,6 +36,8 @@ static int em_text_match(struct sk_buff *skb, struct tcf_ematch *m,
 	int from, to;
 	struct ts_state state;
 
+	memset(&state, 0, sizeof(state));
+
 	from = tcf_get_base_ptr(skb, tm->from_layer) - skb->data;
 	from += tm->from_offset;
 
-- 
2.1.2

Re: [PATCH] net sched: text ematch: zero out ts_state before using it

From: Omar Sandoval <osandov@osandov.com>
Date: 2014-10-09 16:28:40

On Thu, Oct 09, 2014 at 09:05:21AM -0700, Omar Sandoval wrote:
quoted hunk
textsearch_find zeroes out the offset, but the control buffer (which may or may
not matter in this case) needs to be zeroed out as well.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
 net/sched/em_text.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/sched/em_text.c b/net/sched/em_text.c
index 15d353d..2a1b6d9 100644
--- a/net/sched/em_text.c
+++ b/net/sched/em_text.c
@@ -36,6 +36,8 @@ static int em_text_match(struct sk_buff *skb, struct tcf_ematch *m,
 	int from, to;
 	struct ts_state state;
 
+	memset(&state, 0, sizeof(state));
+
 	from = tcf_get_base_ptr(skb, tm->from_layer) - skb->data;
 	from += tm->from_offset;
 
-- 
2.1.2
I forgot to mention: this patch is against 3.17.

-- 
Omar

Re: [PATCH] net sched: text ematch: zero out ts_state before using it

From: Cong Wang <hidden>
Date: 2014-10-09 21:49:03

On Thu, Oct 9, 2014 at 9:05 AM, Omar Sandoval [off-list ref] wrote:
textsearch_find zeroes out the offset, but the control buffer (which may or may
not matter in this case) needs to be zeroed out as well.
Why? skb_prepare_seq_read() initializes the cb.

Also, the comment says:

 * @state: uninitialized textsearch state variable

Re: [PATCH] net sched: text ematch: zero out ts_state before using it

From: Omar Sandoval <osandov@osandov.com>
Date: 2014-10-09 21:54:46

On Thu, Oct 09, 2014 at 02:48:54PM -0700, Cong Wang wrote:
On Thu, Oct 9, 2014 at 9:05 AM, Omar Sandoval [off-list ref] wrote:
quoted
textsearch_find zeroes out the offset, but the control buffer (which may or may
not matter in this case) needs to be zeroed out as well.
Why? skb_prepare_seq_read() initializes the cb.

Also, the comment says:

 * @state: uninitialized textsearch state variable
Mm, thanks, I missed that. It looks like every other caller of skb_find_text is
doing an unnecessary memset in that case. Disregard this, I guess.
-- 
Omar
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help