* [iptables PATCH] extensions: string: Clarify description of --to
@ 2023-10-12 16:08 Phil Sutter
2023-10-12 18:17 ` Phil Sutter
2023-10-12 19:47 ` Pablo Neira Ayuso
0 siblings, 2 replies; 6+ messages in thread
From: Phil Sutter @ 2023-10-12 16:08 UTC (permalink / raw)
To: netfilter-devel
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.
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
extensions/libxt_string.man | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/extensions/libxt_string.man b/extensions/libxt_string.man
index 2a470ece19c9d..efdda492ae78d 100644
--- a/extensions/libxt_string.man
+++ b/extensions/libxt_string.man
@@ -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.
--
2.41.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [iptables PATCH] extensions: string: Clarify description of --to
2023-10-12 16:08 [iptables PATCH] extensions: string: Clarify description of --to Phil Sutter
@ 2023-10-12 18:17 ` Phil Sutter
2023-10-12 19:47 ` Pablo Neira Ayuso
1 sibling, 0 replies; 6+ messages in thread
From: Phil Sutter @ 2023-10-12 18:17 UTC (permalink / raw)
To: netfilter-devel
On Thu, Oct 12, 2023 at 06:08:42PM +0200, Phil Sutter wrote:
> 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.
>
> Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
> Signed-off-by: Phil Sutter <phil@nwl.cc>
Also applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [iptables PATCH] extensions: string: Clarify description of --to
2023-10-12 16:08 [iptables PATCH] extensions: string: Clarify description of --to Phil Sutter
2023-10-12 18:17 ` Phil Sutter
@ 2023-10-12 19:47 ` Pablo Neira Ayuso
2023-10-12 20:14 ` Pablo Neira Ayuso
1 sibling, 1 reply; 6+ messages in thread
From: Pablo Neira Ayuso @ 2023-10-12 19:47 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
On Thu, Oct 12, 2023 at 06:08:42PM +0200, Phil Sutter wrote:
> 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.
>
> Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> extensions/libxt_string.man | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/extensions/libxt_string.man b/extensions/libxt_string.man
> index 2a470ece19c9d..efdda492ae78d 100644
> --- a/extensions/libxt_string.man
> +++ b/extensions/libxt_string.man
> @@ -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.
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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [iptables PATCH] extensions: string: Clarify description of --to
2023-10-12 19:47 ` Pablo Neira Ayuso
@ 2023-10-12 20:14 ` Pablo Neira Ayuso
2023-10-13 9:28 ` Phil Sutter
0 siblings, 1 reply; 6+ messages in thread
From: Pablo Neira Ayuso @ 2023-10-12 20:14 UTC (permalink / raw)
To: Phil Sutter; +Cc: netfilter-devel
On Thu, Oct 12, 2023 at 09:47:38PM +0200, Pablo Neira Ayuso wrote:
> On Thu, Oct 12, 2023 at 06:08:42PM +0200, Phil Sutter wrote:
> > 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.
> >
> > Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> > extensions/libxt_string.man | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/extensions/libxt_string.man b/extensions/libxt_string.man
> > index 2a470ece19c9d..efdda492ae78d 100644
> > --- a/extensions/libxt_string.man
> > +++ b/extensions/libxt_string.man
> > @@ -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.
>
> 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?
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [iptables PATCH] extensions: string: Clarify description of --to
2023-10-12 20:14 ` Pablo Neira Ayuso
@ 2023-10-13 9:28 ` Phil Sutter
2023-10-13 10:08 ` Pablo Neira Ayuso
0 siblings, 1 reply; 6+ messages in thread
From: Phil Sutter @ 2023-10-13 9:28 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On Thu, Oct 12, 2023 at 10:14:31PM +0200, Pablo Neira Ayuso wrote:
> On Thu, Oct 12, 2023 at 09:47:38PM +0200, Pablo Neira Ayuso wrote:
> > On Thu, Oct 12, 2023 at 06:08:42PM +0200, Phil Sutter wrote:
> > > 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.
> > >
> > > Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
> > > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > > ---
> > > extensions/libxt_string.man | 8 ++++++--
> > > 1 file changed, 6 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/extensions/libxt_string.man b/extensions/libxt_string.man
> > > index 2a470ece19c9d..efdda492ae78d 100644
> > > --- a/extensions/libxt_string.man
> > > +++ b/extensions/libxt_string.man
> > > @@ -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.
> >
> > 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?
>
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [iptables PATCH] extensions: string: Clarify description of --to
2023-10-13 9:28 ` Phil Sutter
@ 2023-10-13 10:08 ` Pablo Neira Ayuso
0 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2023-10-13 10:08 UTC (permalink / raw)
To: Phil Sutter, netfilter-devel
On Fri, Oct 13, 2023 at 11:28:53AM +0200, Phil Sutter wrote:
> On Thu, Oct 12, 2023 at 10:14:31PM +0200, Pablo Neira Ayuso wrote:
> > On Thu, Oct 12, 2023 at 09:47:38PM +0200, Pablo Neira Ayuso wrote:
> > > On Thu, Oct 12, 2023 at 06:08:42PM +0200, Phil Sutter wrote:
> > > > 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.
> > > >
> > > > Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1707
> > > > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > > > ---
> > > > extensions/libxt_string.man | 8 ++++++--
> > > > 1 file changed, 6 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/extensions/libxt_string.man b/extensions/libxt_string.man
> > > > index 2a470ece19c9d..efdda492ae78d 100644
> > > > --- a/extensions/libxt_string.man
> > > > +++ b/extensions/libxt_string.man
> > > > @@ -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.
> > >
> > > 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?
> >
> > 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-10-13 10:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 16:08 [iptables PATCH] extensions: string: Clarify description of --to Phil Sutter
2023-10-12 18:17 ` Phil Sutter
2023-10-12 19:47 ` Pablo Neira Ayuso
2023-10-12 20:14 ` Pablo Neira Ayuso
2023-10-13 9:28 ` Phil Sutter
2023-10-13 10:08 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).