extensions: string: Clarify description of --to
Phil Sutter
reviewerPATCH 1/1 extensions: string: Clarify description of --to
String match indeed returns a match as long as the given pattern starts in the range of --from and --to, update the text accordingly. Also add a note regarding fragment boundaries.
--- extensions/libxt_string.man | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
extensions/libxt_string.man +6 -2
@@ -7,9 +7,13 @@ Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri Set the offset from which it starts looking for any matching. If not passed, default is 0. .TP \fB\-\-to\fP \fIoffset\fP -Set the offset up to which should be scanned. That is, byte \fIoffset\fP-1 -(counting from 0) is the last one that is scanned. +Set the offset up to which should be scanned. If the pattern does not start +within this offset, it is not considered a match. If not passed, default is the packet size. +A second function of this parameter is instructing the kernel how much data +from the packet should be provided. With non-linear skbuffs (e.g. due to +fragmentation), a pattern extending past this offset may not be found. Also see +the related note below about Boyer-Moore algorithm in these cases. .TP [\fB!\fP] \fB\-\-string\fP \fIpattern\fP Matches the given pattern.
Signature · 1 line
2.41.0
Phil Sutter
reviewerQuoted 6 lines · Phil Sutter
String match indeed returns a match as long as the given pattern starts in the range of --from and --to, update the text accordingly. Also add a note regarding fragment boundaries.
Signed-off-by Phil Sutter <[email protected]>
Also applied.
Pablo Neira Ayuso
maintainerQuoted 17 lines · Phil Sutter
String match indeed returns a match as long as the given pattern starts in the range of --from and --to, update the text accordingly. Also add a note regarding fragment boundaries.
Signed-off-by Phil Sutter <[email protected]>--- extensions/libxt_string.man | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)extensions/libxt_string.man +0
-0@@ -7,9 +7,13 @@ Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri Set the offset from which it starts looking for any matching. If not passed, default is 0. .TP
extensions/libxt_string.man Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri · line 16
Quoted 10 lines
extensions/libxt_string.man +6
-2\fB\-\-to\fP \fIoffset\fP -Set the offset up to which should be scanned. That is, byte \fIoffset\fP-1 -(counting from 0) is the last one that is scanned. +Set the offset up to which should be scanned. If the pattern does not start +within this offset, it is not considered a match. If not passed, default is the packet size. +A second function of this parameter is instructing the kernel how much data +from the packet should be provided. With non-linear skbuffs (e.g. due to +fragmentation), a pattern extending past this offset may not be found. Also see +the related note below about Boyer-Moore algorithm in these cases.
Then, matching on:
- linear skbuff: if the pattern falls within from-to, all good.
- non-linear skbuff: if pattern falls within from-to, but remaining patter
This is clearly broken, the fix is just to document this?
No attempt to fix it this from the kernel?
Pablo Neira Ayuso
maintainerQuoted 31 lines · Pablo Neira Ayuso
Quoted 17 lines · Phil Sutter
String match indeed returns a match as long as the given pattern starts in the range of --from and --to, update the text accordingly. Also add a note regarding fragment boundaries.
Signed-off-by Phil Sutter <[email protected]>--- extensions/libxt_string.man | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)extensions/libxt_string.man +0
-0@@ -7,9 +7,13 @@ Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri Set the offset from which it starts looking for any matching. If not passed, default is 0. .TPextensions/libxt_string.man Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri · line 16
Quoted 10 lines
extensions/libxt_string.man +6
-2\fB\-\-to\fP \fIoffset\fP -Set the offset up to which should be scanned. That is, byte \fIoffset\fP-1 -(counting from 0) is the last one that is scanned. +Set the offset up to which should be scanned. If the pattern does not start +within this offset, it is not considered a match. If not passed, default is the packet size. +A second function of this parameter is instructing the kernel how much data +from the packet should be provided. With non-linear skbuffs (e.g. due to +fragmentation), a pattern extending past this offset may not be found. Also see +the related note below about Boyer-Moore algorithm in these cases.Then, matching on:
Quoted 7 lines
- linear skbuff: if the pattern falls within from-to, all good.
- non-linear skbuff: if pattern falls within from-to, but remaining patterThis is clearly broken, the fix is just to document this?
No attempt to fix it this from the kernel?
I would align linear skbuff behaviour to how non-linear skbuff works, that is, pattern matching stops at to. This requires a small patch for xt_string.
Phil Sutter
reviewerQuoted 36 lines · Pablo Neira Ayuso
Quoted 35 lines · Pablo Neira Ayuso
Quoted 17 lines · Phil Sutter
String match indeed returns a match as long as the given pattern starts in the range of --from and --to, update the text accordingly. Also add a note regarding fragment boundaries.
Signed-off-by Phil Sutter <[email protected]>--- extensions/libxt_string.man | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)extensions/libxt_string.man +0
-0@@ -7,9 +7,13 @@ Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri Set the offset from which it starts looking for any matching. If not passed, default is 0. .TPextensions/libxt_string.man Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri · line 16
Quoted 10 lines
extensions/libxt_string.man +6
-2\fB\-\-to\fP \fIoffset\fP -Set the offset up to which should be scanned. That is, byte \fIoffset\fP-1 -(counting from 0) is the last one that is scanned. +Set the offset up to which should be scanned. If the pattern does not start +within this offset, it is not considered a match. If not passed, default is the packet size. +A second function of this parameter is instructing the kernel how much data +from the packet should be provided. With non-linear skbuffs (e.g. due to +fragmentation), a pattern extending past this offset may not be found. Also see +the related note below about Boyer-Moore algorithm in these cases.Then, matching on:
- linear skbuff: if the pattern falls within from-to, all good.
- non-linear skbuff: if pattern falls within from-to, but remaining patter
Quoted 7 lines
Quoted 3 lines
This is clearly broken, the fix is just to document this?
No attempt to fix it this from the kernel?
I would align linear skbuff behaviour to how non-linear skbuff works, that is, pattern matching stops at to. This requires a small patch for
xt_string.
Sounds reasonable. My efforts at documenting the current behaviour probably show how unintuitive this currently is.
Thanks for the suggestion!
Cheers, Phil
Pablo Neira Ayuso
maintainerQuoted 39 lines · Phil Sutter
Quoted 38 lines · Pablo Neira Ayuso
Quoted 37 lines · Pablo Neira Ayuso
Quoted 17 lines · Phil Sutter
String match indeed returns a match as long as the given pattern starts in the range of --from and --to, update the text accordingly. Also add a note regarding fragment boundaries.
Signed-off-by Phil Sutter <[email protected]>--- extensions/libxt_string.man | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)extensions/libxt_string.man +0
-0@@ -7,9 +7,13 @@ Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri Set the offset from which it starts looking for any matching. If not passed, default is 0. .TPextensions/libxt_string.man Select the pattern matching strategy. (bm = Boyer-Moore, kmp = Knuth-Pratt-Morri · line 16
Quoted 10 lines
extensions/libxt_string.man +6
-2\fB\-\-to\fP \fIoffset\fP -Set the offset up to which should be scanned. That is, byte \fIoffset\fP-1 -(counting from 0) is the last one that is scanned. +Set the offset up to which should be scanned. If the pattern does not start +within this offset, it is not considered a match. If not passed, default is the packet size. +A second function of this parameter is instructing the kernel how much data +from the packet should be provided. With non-linear skbuffs (e.g. due to +fragmentation), a pattern extending past this offset may not be found. Also see +the related note below about Boyer-Moore algorithm in these cases.Then, matching on:
- linear skbuff: if the pattern falls within from-to, all good.
- non-linear skbuff: if pattern falls within from-to, but remaining patterThis is clearly broken, the fix is just to document this?
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
No attempt to fix it this from the kernel?
I would align linear skbuff behaviour to how non-linear skbuff works, that is, pattern matching stops at to. This requires a small patch for
xt_string.Sounds reasonable. My efforts at documenting the current behaviour probably show how unintuitive this currently is.
I'd suggest you fix it from skb_find_text() to discard a match if it goes over the "--to" boundary.
I think the "slidding" matching after the to boundary (that only works with linear skbuff) is something the user does not want, when they specify a [ from, to ] range, they really mean to narrow it down to such range.
And if the user ever wants this, a flag could be exposed to provide such behaviour.
Thanks.