From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <yuehaibing@huawei.com>
Cc: <davem@davemloft.net>, <dsahern@kernel.org>,
<edumazet@google.com>, <kuba@kernel.org>, <kuni1840@gmail.com>,
<kuniyu@amazon.com>, <netdev@vger.kernel.org>,
<pabeni@redhat.com>, <wangyufen@huawei.com>
Subject: Re: [PATCH v2 net] icmp6: Fix null-ptr-deref of ip6_null_entry->rt6i_idev in icmp6_dev().
Date: Fri, 7 Jul 2023 18:40:06 -0700 [thread overview]
Message-ID: <20230708014006.86743-1-kuniyu@amazon.com> (raw)
In-Reply-To: <8ae0ccf3-0e88-f968-037d-f7f2a1d7ba9a@huawei.com>
From: YueHaibing <yuehaibing@huawei.com>
Date: Sat, 8 Jul 2023 09:35:27 +0800
> On 2023/7/8 8:21, Kuniyuki Iwashima wrote:
> > With some IPv6 Ext Hdr (RPL, SRv6, etc.), we can send a packet that
> > has the link-local address as src and dst IP and will be forwarded to
> > an external IP in the IPv6 Ext Hdr.
> >
> > For example, the script below generates a SRv6 packet whose src IP is
> > the link-local address and dst is updated to 11::.
> >
> > # for f in $(find /proc/sys/net/ -name *seg6_enabled*); do echo 1 > $f; done
> > # python3
> > >>> from socket import *
> > >>> from scapy.all import *
> > >>>
> > >>> SRC_ADDR = DST_ADDR = "fe80::5054:ff:fe12:3456"
> > >>>
> > >>> pkt = IPv6(src=SRC_ADDR, dst=DST_ADDR)
> > >>> pkt /= IPv6ExtHdrSegmentRouting(type=4, addresses=["11::", "22::"], segleft=1)
> > >>>
> > >>> sk = socket(AF_INET6, SOCK_RAW, IPPROTO_RAW)
> > >>> sk.sendto(bytes(pkt), (DST_ADDR, 0))
> >
> > For such a packet, we call ip6_route_input() to look up a route for the
> > next destination in these three functions depending on the header type.
> >
> > * ipv6_rthdr_rcv()
> > * ipv6_rpl_srh_rcv()
> > * ipv6_srh_rcv()
> >
> > If no route is found, ip6_null_entry is set to skb, and the following
> > dst_input(skb) calls ip6_pkt_drop().
> >
> > Finally, in icmp6_dev(), we dereference skb_rt6_info(skb)->rt6i_idev->dev
> > as the input device is the loopback interface. Then, we have to check if
> > skb_rt6_info(skb)->rt6i_idev is NULL or not to avoid NULL pointer deref
> > for ip6_null_entry.
> >
> ...
>
> > Fixes: 4832c30d5458 ("net: ipv6: put host and anycast routes on device with address")
> > Reported-by: Wang Yufen <wangyufen@huawei.com>
>
> > Closes: https://lore.kernel.org/netdev/1ddf7fc8-bcb3-ab48-4894-24158e8a9d0f@huawei.com/
>
> This link seems not right.
Ah... exactly.
I'll fix it up in v3.
https://lore.kernel.org/netdev/c41403a9-c2f6-3b7e-0c96-e1901e605cd0@huawei.com/
Thanks!
--
pw-bot: cr
prev parent reply other threads:[~2023-07-08 1:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-08 0:21 [PATCH v2 net] icmp6: Fix null-ptr-deref of ip6_null_entry->rt6i_idev in icmp6_dev() Kuniyuki Iwashima
2023-07-08 1:35 ` YueHaibing
2023-07-08 1:40 ` Kuniyuki Iwashima [this message]
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=20230708014006.86743-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wangyufen@huawei.com \
--cc=yuehaibing@huawei.com \
/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).