[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6564bbd5580de_8a1ac29481@willemb.c.googlers.com.notmuch>
Date: Mon, 27 Nov 2023 10:55:01 -0500
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Shigeru Yoshida <syoshida@...hat.com>,
davem@...emloft.net,
dsahern@...nel.org,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com
Cc: netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
Shigeru Yoshida <syoshida@...hat.com>
Subject: Re: [PATCH net] ipv4: ip_gre: Handle skb_pull() failure in
ipgre_xmit()
Shigeru Yoshida wrote:
> In ipgre_xmit(), skb_pull() may fail even if pskb_inet_may_pull() returns
> true. For example, applications can create a malformed packet that causes
> this problem with PF_PACKET.
It may fail because because pskb_inet_may_pull does not account for
tunnel->hlen.
Is that what you are referring to with malformed packet? Can you
eloborate a bit on in which way the packet has to be malformed to
reach this?
FYI: I had a quick look at the IPv6 equivalent code.
ip6gre_tunnel_xmit is sufficiently different. It makes sense that this
is an IPv4 only patch.
> This patch fixes the problem by dropping skb and returning from the
> function if skb_pull() fails.
>
> Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
> Signed-off-by: Shigeru Yoshida <syoshida@...hat.com>
> ---
> net/ipv4/ip_gre.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
> index 22a26d1d29a0..95efa97cb84b 100644
> --- a/net/ipv4/ip_gre.c
> +++ b/net/ipv4/ip_gre.c
> @@ -643,7 +643,8 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
> /* Pull skb since ip_tunnel_xmit() needs skb->data pointing
> * to gre header.
> */
> - skb_pull(skb, tunnel->hlen + sizeof(struct iphdr));
> + if (!skb_pull(skb, tunnel->hlen + sizeof(struct iphdr)))
> + goto free_skb;
> skb_reset_mac_header(skb);
>
> if (skb->ip_summed == CHECKSUM_PARTIAL &&
> --
> 2.41.0
>
Powered by blists - more mailing lists