๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15412

Re: [PATCH net v2 2/4] ipv4: restrict on-link fallback to lookup misses

#15412
From: netdev-bot+sashiko
Date: Thu, 12 Nov 2026 21:17
124 lines
12345 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix is incomplete for route-based restrictions.

--

ipv4: restrict on-link fallback to lookup misses

This patch changes ip_route_output_key_hash_rcu() to call fib_lookup()
with FIB_LOOKUP_REPORT_MISS. For non-vrf unicast with an oif set, the
on-link fallback is then only taken on a real lookup miss (-ESRCH).
Before this, it was taken for any fib_lookup() error, so blackhole,
prohibit and unreachable restrictions could be bypassed.

> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 3a90c8d28b940..80a2c8a3c571f 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -2851,12 +2851,13 @@ struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
>  		goto make_route;
>  	}
>  
> -	err = fib_lookup(net, fl4, res, 0);
> +	err = fib_lookup(net, fl4, res, FIB_LOOKUP_REPORT_MISS);
>  	if (err) {
>  		res->fi = NULL;
>  		res->table = NULL;
>  		if (fl4->flowi4_oif &&
> -		    (ipv4_is_multicast(fl4->daddr) || !fl4->flowi4_l3mdev)) {
> +		    (ipv4_is_multicast(fl4->daddr) ||
> +		     (!fl4->flowi4_l3mdev && err == -ESRCH))) {

[Severity: High]
Can a reject route that scope filtering skips still show up here as
-ESRCH and take the on-link fallback?

An unprivileged socket can set an oif with IP_UNICAST_IF, IP_PKTINFO or
SO_BINDTODEVICE. It can then send with MSG_DONTROUTE, or set
SO_DONTROUTE, which needs no capability. Either way, ip_sendmsg_scope()
returns RT_SCOPE_LINK:

include/net/ip.h:ip_sendmsg_scope() {
	if (sock_flag(&inet->sk, SOCK_LOCALROUTE) ||
	    msg->msg_flags & MSG_DONTROUTE ||
	    (ipc->opt && ipc->opt->opt.is_strictroute))
		return RT_SCOPE_LINK;
    ...
}

udp_sendmsg() passes that scope into flowi4_init_output(), so
fl4->flowi4_scope is RT_SCOPE_LINK by the time fib_lookup() runs.

In fib_table_lookup(), the scope check comes before the reject-type
error check:

net/ipv4/fib_trie.c:fib_table_lookup() {
    ...
		if (fa->fa_info->fib_scope < flp->flowi4_scope)
			continue;
		fib_alias_accessed(fa);
		err = fib_props[fa->fa_type].error;
    ...
}

By default, prohibit, blackhole and unreachable routes have
RT_SCOPE_UNIVERSE, which fib_props allows. So a link-scope lookup skips
them instead of returning -EACCES, -EINVAL or -EHOSTUNREACH.

If the destination is off-link and there is no link-scope route, the
lookup ends in -EAGAIN. Because FIB_LOOKUP_REPORT_MISS is set,
fib_lookup() turns that into -ESRCH, and so does
__fib_lookup()->fib_rules_lookup() when it runs out of rules. The new
err == -ESRCH check then passes, and a route through dev_out gets built.

The full path looks like this:

udp_sendmsg()
  ip_sendmsg_scope()               -> RT_SCOPE_LINK
  ip_route_output_flow()
    ip_route_output_key_hash_rcu()
      fib_lookup(..., FIB_LOOKUP_REPORT_MISS)
        fib_table_lookup()         reject alias skipped, -EAGAIN
      err == -ESRCH                on-link fallback taken

On NOARP or point-to-point links, like the cellular case in the commit
message, would the packet then go out the interface the prohibit route
was meant to block?

The commit message says:

    As a result, routes and rules that are supposed to restrict traffic
    (blackhole, prohibit, unreachable) are unable to do so
    comprehensively.

This looks fixed for rules. fib4_rule_action() returns -EACCES,
-ENETUNREACH or -EINVAL without any scope filtering. Routes seem to
still be bypassable with DONTROUTE plus an oif.

The comment added later by "ipv4: replace obsolete routing comment"
also says "Non-vrf unicast does honor restrictions". That commit calls
the old MSG_DONTROUTE description obsolete, but this case would still
apply to it.

Would it make sense to stop treating scope-filtered reject matches as
misses, or to handle the scope case separately?

>  			/* Apparently, routing tables are wrong. Assume,
>  			 * that the destination is on link.
>  			 *

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110061536.10811-1-liamsmith827%40grapheneos.org
Technical Details
Message-ID: <179451823511.2199510.15480690224597348773@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362219-linux-kernel-netdev=dewy.ru
References: <20261110061536.10811-3-liamsmith827@grapheneos.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362219-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 2/4] ipv4: restrict on-link fallback to lookup misses
Date: Thu, 12 Nov 2026 21:17:15 +0000
Organization: Usenet Network
Message-ID: <179451823511.2199510.15480690224597348773@kernel.org>
References: <20261110061536.10811-3-liamsmith827@grapheneos.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1189743"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Fjyc9wMfLyzzrx7zksfVcDL7t+E= sha256:zeAgOSbvH6Ay4rcTclu/1ydG1sqJBWfqlXpFVuvJlpo=
	sha1:24ixZwR2dVCrgPfbQFD8SoZjAlY= sha256:nKt1IVZn3eHbfMi/t350bUgrlMPE8O6d2A/c5bOb3EQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D14E711439F; Fri, 13 Nov 2026 01:07:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id JgqEqt8GXDA7;
	Fri, 13 Nov 2026 01:07:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-362219-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id CA9E9114096; Fri, 13 Nov 2026 01:07:29 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 90BAD1C22A9; Thu, 12 Nov 2026 21:17:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794518237;
	b=So8F/jKfbZSvM0B2NqiAaZsyKt/FNJAMaJ+uW49k5HCXAmqFyc2syJ2Vqfy2pNu2jmUj
	 w6dIx+hURxPbzYPg19w3ziQnyDoS5pSRZdsv/8JS3pSGWItBvRDYFz8htdbZoHoGjwGwQ
	 tIzC6YQP84e9/Jy7hx8bbMVqrUrVx3Khkrr6OaFXw5rYeRuRuZntTo6K/Bp7M5UQh0ZYS
	 b4BQtGKP989KYHNjNctClA/0FpfXGBec+NuiEpyfGXLSZW4XxlWKxpOJnHs6OY5mv1PY3
	 28MSEaWBKYQcgRpthvW+sDQwlPsT5ZONYLqxV/CSU7bhqB35p06rXOcBHwA8ZEx1jYw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794518237;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=nCeolnG7xjqaBJL8tNZxUEnHawYs1R1nNtrCWLAobc0=;
	b=Ir99gvLMufQoCdAJpUjav9Lxf+ghgayIuFkp9yhLGyk3o20V/xiyCLECrYox0EY5JP3M
	 lTeqelLgekUe/+grSNwMk7E+yBzfVz0yZBjkscmkgA8xNDH1TowvarHozmPNG1lDjafWd
	 rR/8ChMFLybp9ggZ7M8e445RsnT2laoN3FZj1NmrOOixi4uP5B2jF+opVP/RHBwwp011p
	 MpexTcEJ81PWhXfLeK9I9kvphLjm48Ndi40t3nsWFyx91ugtOpGCK3LS/GYg83SEYbH0M
	 Qi58TnxdXpz4GVRV0UTRr/lweG+Fl9V961JP2PcxS7i4s/lHYDUEtbcKH6nJe/2z+Eg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UtAcJnIn;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A7099606A334;
	Thu, 12 Nov 2026 21:17:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UtAcJnIn
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794518236;
	b=qSbBbkUNAR7fgeaUHImmMFqwKZ62Gi/JebijknTARsvU0OXq3TLi+XGQ7oLuKrI3A2I2
	 Mi29qc4dV3D/3sSUKPovm60pYfTQjpoRZ/+CzQLjBT8MxToztW8tCD4Iq1d39hzGs8AJw
	 8wpD7wK20wrVXcKI0yfvEP87wNyz88NAM0I5NQXYcEgZr2rYO3dd7mINGjl6tFrnfv0Ho
	 D0chsqwbCy0lHsKIRGJavof1hGp65ZCqewH0c9mKfql5zavjWfoAkxHR2rRgBpdfvhKhj
	 c23VkvcPnB5Y8jdFM3dil3HaoUzoiQLnCxN5e4S2og/4cdn5bNTfSFVFvPNkuM/A8zA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794518236;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=nCeolnG7xjqaBJL8tNZxUEnHawYs1R1nNtrCWLAobc0=;
	b=Bn6BN9ABkXj2aCMMLAKhXkbUvRd8CCxuuEiMjfNmwTgnLreOsRH/ESmTJ14SP+WAZaFD
	 2nT6qBwXjcv4QIKpeB54teRLNu9WJQjy1dF3FsXJAouj5uR0DayerHIK42WYJEtSnHzik
	 UG5Xnjl1x3wDweseioEr4g1y5iZyAnLkYD+W4p0zidLsAjNbF98vmzCq1qvYEv6vYrVq/
	 oRdf00K8TKkg8NxOE2XqD6PQSaSfLpSwb0m47CvZe8PXPSGnnjwP4RUeTqXeLD2X8Tjqk
	 W2M14x9mq4gvFrKXbugR1WYrbZ8+6RuP9/F12uUD4mL5AW16K88GYlNjRF4V3DgPV8g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UtAcJnIn;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3CCC606A31C;
	Thu, 12 Nov 2026 21:17:16 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C7B51F000C4;
	Thu, 12 Nov 2026 21:17:15 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794518236;
	bh=nCeolnG7xjqaBJL8tNZxUEnHawYs1R1nNtrCWLAobc0=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=UtAcJnInrsx/Yo1EkpKK/o6/1cGbqiQMpEizHK5gUp48dXpXAkLzPHDrjOKg3ZFU8
	 d+67RcpXYxexgxkt9Q4e60+IfbF3OytLOuYRwk/TFRe5GSuXrTRqhl/eckP/2DlDEt
	 79tx+jNdESdRE5bAihtN896sjxaSWaJ4XCdKyyscDNO5g0AAIDrkXl41noLUb4LcGP
	 bLko8YrnkpFSr/IGQe86OQJPciS6KlYFR9jH7xIFyNvvhv6/LG71iaBMngM61wf5/O
	 OLqeIzEa1jYxNN1fh8cRHJ+EAVK9wGwPrCTyUYjQwJv5ECYO8CHWL528y56Tn4XWpj
	 z2hxKurAxcHeQ==
X-Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 horms@kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org,
 linux-kernel@vger.kernel.org, liamsmith827@proton.me
X-In-Reply-To: <20261110061536.10811-3-liamsmith827@grapheneos.org>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list