From: "dongchenchen (A)" <dongchenchen2@huawei.com>
To: <dsahern@kernel.org>, <idosch@nvidia.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
<horms@kernel.org>, <herbert@gondor.apana.org.au>
Cc: <netdev@vger.kernel.org>, <zhangchangzhong@huawei.com>
Subject: Re: [PATCH net] ipv4: icmp: reject non-unicast input routes in icmp_route_lookup
Date: Fri, 14 Aug 2026 19:20:29 +0800 [thread overview]
Message-ID: <9e3ff760-69ec-4ecc-8256-d065db6c2af6@huawei.com> (raw)
In-Reply-To: <20260811133037.3344927-1-dongchenchen2@huawei.com>
> When the forward output route cannot be used in icmp_route_lookup(),
> it enters the "reverse path" and calls ip_route_input() on fl4_dec.daddr,
> the original packet's source address.
>
> ip_route_input() only returns an error for truly invalid packets. For
> local, broadcast, multicast and unreachable addresses it still succeeds
> and returns an input route whose dst.output is set to ip_rt_bug(). The
> existing check only rejects RTN_LOCAL routes, so the other route types
> can still be returned and later used for output, syzkaller triggering a
> WARN_ON_ONCE() in ip_rt_bug() as bellow:
>
> ------------[ cut here ]------------
> WARNING: net/ipv4/route.c:1273 at ip_rt_bug+0x14/0x20
> RIP: 0010:ip_rt_bug+0x14/0x20
> Call Trace:
> ip_push_pending_frames+0xfa/0x100
> __icmp_send+0x905/0xf10
> ip_options_compile+0xc0/0xd0
> ip_rcv_finish_core+0x321/0xae0
> ip_rcv+0x1de/0x260
> __netif_receive_skb_one_core+0x11a/0x130
> netif_receive_skb+0x7b/0x260
> tun_get_user+0x11bf/0x1c10
> ------------[ cut here ]------------
>
> If the original source address is unroutable, ip_route_input() returns a
> RTN_UNREACHABLE input route with err == 0, and the ICMP reply is then sent
> through ip_rt_bug().
>
> Only RTN_UNICAST input routes have dst.output set to ip_output() and are
> safe to use for output. Reject any input route that is not RTN_UNICAST.
>
> Fixes: 8b7817f3a959 ("[IPSEC]: Add ICMP host relookup support")
> Signed-off-by: Dong Chenchen <dongchenchen2@huawei.com>
> ---
> net/ipv4/icmp.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
> index 0caedfc7ca92..d58ac2f23f9f 100644
> --- a/net/ipv4/icmp.c
> +++ b/net/ipv4/icmp.c
> @@ -584,12 +584,14 @@ static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4,
> * At this point, fl4_dec.daddr should NOT be local (we
> * checked fl4_dec.saddr above). However, a race condition
> * may occur if the address is added to the interface
> - * concurrently. In that case, ip_route_input() returns a
> - * LOCAL route with dst.output=ip_rt_bug, which must not
> - * be used for output.
> + * concurrently, or if fl4_dec.daddr is otherwise unroutable.
> + * In that case, ip_route_input() returns an input route
> + * (RTN_LOCAL, RTN_BROADCAST, RTN_UNREACHABLE or
> + * RTN_MULTICAST) with dst.output set to ip_rt_bug(), which
> + * must not be used for output.
> */
> - if (!err && rt2 && rt2->rt_type == RTN_LOCAL) {
> - net_warn_ratelimited("detected local route for %pI4 during ICMP sending, src %pI4\n",
> + if (!err && rt2 && rt2->rt_type != RTN_UNICAST) {
sorry, this judgement will reject bforward packet.
broadcast and multicast rt with ip_rt_bug has been reject after
icmp_route_lookup.We only need to add a judgment for RTN_UNREACHABLE
v2 will be sent.
best regards
Dong Chenchen> + net_warn_ratelimited("detected unusable input route
for %pI4 during ICMP sending, src %pI4\n",
> &fl4_dec.daddr, &fl4_dec.saddr);
> dst_release(&rt2->dst);
> err = -EINVAL;
prev parent reply other threads:[~2026-08-14 11:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 13:30 [PATCH net] ipv4: icmp: reject non-unicast input routes in icmp_route_lookup Dong Chenchen
2026-08-14 11:20 ` dongchenchen (A) [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=9e3ff760-69ec-4ecc-8256-d065db6c2af6@huawei.com \
--to=dongchenchen2@huawei.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=zhangchangzhong@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