🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18809

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

#18809
From: netdev-bot+sashiko
Date: Wed, 18 Nov 2026 23:28
138 lines
13140 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

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] Route-based restrictions can still be bypassed by an
  unprivileged process after this fix.
- [Low] The commit message describes a security-relevant bug that users
  can see: unprivileged Android apps can get around a VPN kill switch…

--

ipv4: restrict on-link fallback to lookup misses

With this patch, ip_route_output_key_hash_rcu() takes the oif-bound
on-link fallback for non-vrf unicast only when fib_lookup() reports a
real lookup miss (-ESRCH, via FIB_LOOKUP_REPORT_MISS). Errors from
blackhole, prohibit and unreachable routes or rules now go back to the
caller, and -ESRCH is mapped back to -ENETUNREACH.

> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index b9f5397336d34..b71443e4b522c 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -2859,12 +2859,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);

[Severity: Low]
The commit message describes a security-relevant problem that users can
see: unprivileged apps can bypass the Android VPN kill switch. There is
no Fixes: tag and no Cc: stable, though.

The unconditional on-link fallback in ip_route_output_key_hash_rcu()
dates back to the initial git import. Should this carry something like
the following?

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

A Fixes: tag would also make it clearer whether this is meant for net
or net-next.

This change also depends on the earlier patch "ipv4: add
FIB_LOOKUP_REPORT_MISS". A backport of this patch alone would fail to
build, because FIB_LOOKUP_REPORT_MISS would be undefined, so it would
not misbehave silently. If this is meant for stable, could the
dependency be stated?

>  	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 route-based restrictions still be bypassed here when the flow asks
for link scope?

The commit message says this fixes "routes and rules that are supposed
to restrict traffic (blackhole, prohibit, unreachable)".

An unprivileged process can bind to a device (SO_BINDTODEVICE,
IP_UNICAST_IF, IP_PKTINFO) and also set SO_DONTROUTE or MSG_DONTROUTE.
Neither needs a capability. In that case ip_sendmsg_scope() returns
RT_SCOPE_LINK, and so does ip_sock_rt_scope() for connect and TCP:

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;
    ...
}

In fib_table_lookup(), the scope check runs before the reject error is
read:

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;
    ...
}

Blackhole, prohibit and unreachable routes have universe scope by
default. fib_create_info() keeps cfg->fc_scope for reject types, and
iproute2 creates them with universe scope. A link-scope flow therefore
skips the reject route as if it were not there.

The table then returns -EAGAIN. Because of FIB_LOOKUP_REPORT_MISS,
fib_lookup() turns that into -ESRCH, and so does __fib_lookup() ->
fib_rules_lookup() when custom rules exist.

The condition above then holds, and the code jumps to make_route with an
RTN_UNICAST route on the chosen device. For example:

  ping -r -I eth1 <blocked dst>

That packet would still seem to go out eth1, even with a prohibit route
for that destination. Before this patch every error fell back. After it,
the same bypass needs just one more unprivileged socket option.

Rule actions (FR_ACT_PROHIBIT, FR_ACT_UNREACHABLE and FR_ACT_BLACKHOLE
in fib4_rule_action()) are not filtered by scope. So the kill switch
built on prohibit rules does look fixed, and only the route case
remains open.

Could the fallback tell a real miss apart from a reject route that was
skipped only because of scope? Another option would be to not apply the
scope filter to reject-type aliases when deciding whether to fall back.

A later patch in the series, "ipv4: replace obsolete routing comment",
adds the comment "Non-vrf unicast honors restrictions", which does not
hold in this case either. Nothing later in the series changes
fib_trie.c or this condition.

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

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116202741.13106-1-liamsmith827%40grapheneos.org
Technical Details
Message-ID: <179504450812.3136.16231358596487999009@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366511-linux-kernel-netdev=dewy.ru
References: <20261116202741.13106-3-liamsmith827@grapheneos.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366511-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 2/4] ipv4: restrict on-link fallback to lookup misses
Date: Wed, 18 Nov 2026 23:28:28 +0000
Organization: Usenet Network
Message-ID: <179504450812.3136.16231358596487999009@kernel.org>
References: <20261116202741.13106-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="2728515"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ZFvHbahFR3Fdc/NWlqff5vGIuFQ= sha256:IpzlO5LECo+XMDDDw6ggJd8hQHp2t4tSgrUI2t2KCs4=
	sha1:xD7KOiyrBQZDX2ny6IiYKjM/PmE= sha256:Fqh2CbhMpkZH50hTIjncYsI3EoMA1c1T2hqKXs3LA6I=
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 3314011537B; Thu, 19 Nov 2026 02:28:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 xdqHBWS5rr6M;
	Thu, 19 Nov 2026 02:28:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-366511-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 75E74115415; Thu, 19 Nov 2026 02:28:39 +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 E0CB1C8A74; Wed, 18 Nov 2026 23:28:30 +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=1795044510;
	b=N52Wi6c0kkNpLs/tbdQknTjPj9dS1B5/+Zad/SUaxwiG5jYKu9RHMDUEP1N6n68C2J1E
	 qKzrfBvJAbm3LAmOw0mAPkOttRdyIiHzMZQnU3WsXJa6YWMIk/icEgmvTIFvKsASkb1vn
	 /HUUXWzP8NsOI/VEKBysrp5dvS6zlG5yJSfeQ1x8+bcEjxmsX1kPsJ2GVX3vcAju+sIYI
	 ulsKEbVOmnk3IKSzz1eAgTYqg23f1uT+FolXRXhmetqEsY5PGQ1Rp4atjUOmX4TB7tmgh
	 fUc1s1wn8a4JTMJFnbRhc/MNhDmc+ZZ1Iq4X/vLdkhr//DAyd0yx6bbfaBeCrkfwUBQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795044510;
	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=wZosD5+/Nj2eIGY2Fv4ggxK50RAWtAyE3IvgDSS2SiQ=;
	b=ZDOSQYqM5XCueTxYQCFkMA+QvjnC8nP5qeUCn3I8r4u8MGd7WNqRnMOoMh9SEjPBpKW/
	 0LCfmrmzv6ss4kCRt03kwsPhWDFzu4jEShUz+VTe80psvhigOCH+xHNtCBcCUr3NJyDQS
	 AQIkcf7H/QzEPN/lXcHYbJgmodI/ghmYOIaJPWjfRgU7KDtEG20a++L47C5+GnO4hrW8D
	 7X7cHChvvTB2AeoYREt6I8bplS/+fHog4E+z7+jzeiEOYKa0mCrVjFxSfkNmQWqVpaNz0
	 gPV4IY6fyGcdgnO3oG5CsbNOC/Rbm8wGEjsMfp5/T0tHUg4byMpLwt4SZgtjx1cf0tQ==
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=b2xc3CNk;
	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 453B9606A336;
	Wed, 18 Nov 2026 23:28:30 +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=b2xc3CNk
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=1795044509;
	b=p98jLY70tOhwq5ssyLYMuNqlOfMrJM0WigaBhDhwwae55uU8gKbxRca160uUG8JW0XLp
	 ybN+Ri8oBiAdTXAUx75dgqn3kdnlwi78dzB/XgST89KFKWBgkP7DBJK4FotKTzom1XUiD
	 cKFgiA/4gG3C43hjIY3dMQDMR8sKKkIoSg2PJF5Q/Av03hbECzdw8oXLNofB807YcuvM4
	 vSybIJK5qdxXoLxLF46RcSZb1qnkE+71b3QJ4GzaXSXbo+WRzbRX6cB215wIrHTR+G+3u
	 0zn2yrWdsXekIXNntx0cQyaAKxdzpnxqEsGgdScrKXvrMEN/Ze2UsPSruY5bFnpgUPQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795044509;
	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=wZosD5+/Nj2eIGY2Fv4ggxK50RAWtAyE3IvgDSS2SiQ=;
	b=PIJW4UIqlhLoSUjHuFf/mx+IFxZSVaVDiIOM4ze7F6qRKaBfhXskoUk+JRqIm7bgMT1L
	 We1S3M6BYFq6OBLutY4sQc0hmuQ1lHLTCpKE2jfJvHBAAfA+psvkj4Br8BWCCbx/rmog1
	 ShuXzpo77eDq902y25B8ReY8kr5fH+onNYkBGRpt9LMI3xmGrRXV7fHjg8RV0qX0Hool3
	 vLsIHnokrduG+5VTFRxcw3CPoXqmLXZ+2PzelFPM1qWWXzY811qEKmNhCdK8rrZ9fPKaV
	 H/HGWaZtISdX8JuOhd5pJeoZ08MUfdE1IDxJzQwX/L5r8lwtQiaTg3WAb74e3YJQuog==
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=b2xc3CNk;
	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 63DBD606A32F;
	Wed, 18 Nov 2026 23:28:29 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B9B21F000C4;
	Wed, 18 Nov 2026 23:28:28 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795044509;
	bh=wZosD5+/Nj2eIGY2Fv4ggxK50RAWtAyE3IvgDSS2SiQ=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=b2xc3CNkofjUuaNiWY+44q1putpRhXHx/AV8RXZg+BA/7bJR0Lo0ks54YS2OayOTT
	 sNDHo7QdvE7gDcWsFywJ8u293UOyfQuJ/8XxL8ktOomjMx/jvkQVdmDKFJb9FfxhGr
	 0oBy3fSOCqRaRmIrpr9pr414OJbz3KgThA3TgITErWki7PTEDgpm+9c8m6AlePI3ub
	 sWLekn/m+ZCggtuzRbBgcJQrnOUrDQ8M20dKGy4vw6Om32e2GTv0BFi2EwyvKBnXBn
	 F6RZA9LEl5z+IYmMCFHFVN8aPG1cTJ+vJy1AQy3PJfYeml9dG9yH82g2Lpt6lcPYNJ
	 e9eK+AJXGF1tA==
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: <20261116202741.13106-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