From: David Ahern <dsahern@gmail.com>
To: Andrea Mayer <andrea.mayer@uniroma2.it>,
"David S. Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Yohei Kanemaru <yohei.kanemaru@gmail.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: Stefano Salsano <stefano.salsano@uniroma2.it>,
Paolo Lungaroni <paolo.lungaroni@uniroma2.it>,
Ahmed Abdelsalam <ahabdels.dev@gmail.com>
Subject: Re: [net] seg6: fix the iif in the IPv6 socket control block
Date: Wed, 8 Dec 2021 20:23:23 -0700 [thread overview]
Message-ID: <0a2668a6-e819-926c-f8bd-069957cb3db0@gmail.com> (raw)
In-Reply-To: <20211208195409.12169-1-andrea.mayer@uniroma2.it>
On 12/8/21 12:54 PM, Andrea Mayer wrote:
> When an IPv4 packet is received, the ip_rcv_core(...) sets the receiving
> interface index into the IPv4 socket control block (v5.16-rc4,
> net/ipv4/ip_input.c line 510):
>
> IPCB(skb)->iif = skb->skb_iif;
>
> If that IPv4 packet is meant to be encapsulated in an outer IPv6+SRH
> header, the seg6_do_srh_encap(...) performs the required encapsulation.
> In this case, the seg6_do_srh_encap function clears the IPv6 socket control
> block (v5.16-rc4 net/ipv6/seg6_iptunnel.c line 163):
>
> memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
>
> The memset(...) was introduced in commit ef489749aae5 ("ipv6: sr: clear
> IP6CB(skb) on SRH ip4ip6 encapsulation") a long time ago (2019-01-29).
>
> Since the IPv6 socket control block and the IPv4 socket control block share
> the same memory area (skb->cb), the receiving interface index info is lost
> (IP6CB(skb)->iif is set to zero).
>
> As a side effect, that condition triggers a NULL pointer dereference if
> commit 0857d6f8c759 ("ipv6: When forwarding count rx stats on the orig
> netdev") is applied.
>
> To fix that issue, we set the IP6CB(skb)->iif with the index of the
> receiving interface once again.
>
> Fixes: ef489749aae5 ("ipv6: sr: clear IP6CB(skb) on SRH ip4ip6 encapsulation")
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
> net/ipv6/seg6_iptunnel.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
next prev parent reply other threads:[~2021-12-09 3:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 19:54 [net] seg6: fix the iif in the IPv6 socket control block Andrea Mayer
2021-12-09 3:23 ` David Ahern [this message]
2021-12-09 16:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0a2668a6-e819-926c-f8bd-069957cb3db0@gmail.com \
--to=dsahern@gmail.com \
--cc=ahabdels.dev@gmail.com \
--cc=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paolo.lungaroni@uniroma2.it \
--cc=stefano.salsano@uniroma2.it \
--cc=yohei.kanemaru@gmail.com \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).