diff mbox series

[nf] netfilter: ip6_tables: zero-initialize fragment offset

Message ID 20210912212433.45389-1-jeremy@azazel.net
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nf] netfilter: ip6_tables: zero-initialize fragment offset | expand

Commit Message

Jeremy Sowden Sept. 12, 2021, 9:24 p.m. UTC
ip6tables only sets the `IP6T_F_PROTO` flag on a rule if a protocol is
specified (`-p tcp`, for example).  However, if the flag is not set,
`ip6_packet_match` doesn't call `ipv6_find_hdr` for the skb, in which
case the fragment offset is left uninitialized and a garbage value is
passed to each matcher.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 net/ipv6/netfilter/ip6_tables.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Florian Westphal Sept. 12, 2021, 11:39 p.m. UTC | #1
Jeremy Sowden <jeremy@azazel.net> wrote:
> ip6tables only sets the `IP6T_F_PROTO` flag on a rule if a protocol is
> specified (`-p tcp`, for example).  However, if the flag is not set,
> `ip6_packet_match` doesn't call `ipv6_find_hdr` for the skb, in which
> case the fragment offset is left uninitialized and a garbage value is
> passed to each matcher.

Fixes: f7108a20dee44 ("netfilter: xtables: move extension arguments into compound structure (1/6)"
Reviewed-by: Florian Westphal <fw@strlen.de>
Jeremy Sowden Sept. 13, 2021, 9:28 a.m. UTC | #2
On 2021-09-13, at 01:39:00 +0200, Florian Westphal wrote:
> Jeremy Sowden <jeremy@azazel.net> wrote:
> > ip6tables only sets the `IP6T_F_PROTO` flag on a rule if a protocol
> > is specified (`-p tcp`, for example).  However, if the flag is not
> > set, `ip6_packet_match` doesn't call `ipv6_find_hdr` for the skb, in
> > which case the fragment offset is left uninitialized and a garbage
> > value is passed to each matcher.
>
> Fixes: f7108a20dee44 ("netfilter: xtables: move extension arguments into compound structure (1/6)"
> Reviewed-by: Florian Westphal <fw@strlen.de>

Thanks, Florian.

J.
Pablo Neira Ayuso Sept. 15, 2021, 3:01 p.m. UTC | #3
On Sun, Sep 12, 2021 at 10:24:33PM +0100, Jeremy Sowden wrote:
> ip6tables only sets the `IP6T_F_PROTO` flag on a rule if a protocol is
> specified (`-p tcp`, for example).  However, if the flag is not set,
> `ip6_packet_match` doesn't call `ipv6_find_hdr` for the skb, in which
> case the fragment offset is left uninitialized and a garbage value is
> passed to each matcher.

Applied, thanks.
diff mbox series

Patch

diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index de2cf3943b91..a579ea14a69b 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -273,6 +273,7 @@  ip6t_do_table(struct sk_buff *skb,
 	 * things we don't know, ie. tcp syn flag or ports).  If the
 	 * rule is also a fragment-specific rule, non-fragments won't
 	 * match it. */
+	acpar.fragoff = 0;
 	acpar.hotdrop = false;
 	acpar.state   = state;