diff mbox series

[1/2] net: Allow to and from offsets to be equal in skb_find_text

Message ID 20180226215835.7603-1-bernie.harris@alliedtelesis.co.nz
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series [1/2] net: Allow to and from offsets to be equal in skb_find_text | expand

Commit Message

Bernie Harris Feb. 26, 2018, 9:58 p.m. UTC
The xt_string module uses skb_find_text to match a pattern
against packet data. The current behaviour is that the offsets
are used as the range in which a match can start, with the 'to'
offset being included in that range. This means that to do an
exact match for a string at a specific offset, the 'to' and
'from' offsets need to be equal. However, skb_seq_read does not
allow any data to be read if the offsets are equal.

This patch fixes this behaviour by adding the pattern length to
the 'to' offset when calling skb_prepare_seq_read. This should
not change the behaviour of any existing callers of skb_find_text
since the maximum number of bytes read does not change. This
makes it possible for the xt_string module to do an exact match
for a string at a specific offset.

Signed-off-by: Bernie Harris <bernie.harris@alliedtelesis.co.nz>
---
 net/core/skbuff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 09bd89c90a71..87c5ce401d69 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3353,7 +3353,8 @@  unsigned int skb_find_text(struct sk_buff *skb, unsigned int from,
 	config->get_next_block = skb_ts_get_next_block;
 	config->finish = skb_ts_finish;
 
-	skb_prepare_seq_read(skb, from, to, TS_SKB_CB(&state));
+	skb_prepare_seq_read(skb, from, to + textsearch_get_pattern_len(config),
+			     TS_SKB_CB(&state));
 
 	ret = textsearch_find(config, &state);
 	return (ret <= to - from ? ret : UINT_MAX);