net: skb_find_text: Ignore patterns extending past 'to'
authorPhil Sutter <phil@nwl.cc>
Tue, 17 Oct 2023 09:39:06 +0000 (11:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:51:54 +0000 (11:51 +0100)
commit2acedc5372edbcae99b2f47e89a5efe1e9bbba61
treee756ee750828ba593e6277b45c97a8d8f9e87bc6
parentd860416236bd46c1b9e9586e8d10041cb5ce4e92
net: skb_find_text: Ignore patterns extending past 'to'

[ Upstream commit c4eee56e14fe001e1cff54f0b438a5e2d0dd7454 ]

Assume that caller's 'to' offset really represents an upper boundary for
the pattern search, so patterns extending past this offset are to be
rejected.

The old behaviour also was kind of inconsistent when it comes to
fragmentation (or otherwise non-linear skbs): If the pattern started in
between 'to' and 'from' offsets but extended to the next fragment, it
was not found if 'to' offset was still within the current fragment.

Test the new behaviour in a kselftest using iptables' string match.

Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
Fixes: f72b948dcbb8 ("[NET]: skb_find_text ignores to argument")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/skbuff.c
tools/testing/selftests/netfilter/Makefile
tools/testing/selftests/netfilter/xt_string.sh [new file with mode: 0755]