Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: liamsmith827@grapheneos.org
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
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	[thread overview]
Message-ID: <179504450812.3136.16231358596487999009@kernel.org> (raw)
In-Reply-To: <20261116202741.13106-3-liamsmith827@grapheneos.org>

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

  reply	other threads:[~2026-11-18 23:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 20:27 [PATCH net-next v5 0/4] ipv4: restrict on-link fallback to lookup misses liamsmith827
2026-11-16 20:27 ` [PATCH net-next v5 1/4] ipv4: add FIB_LOOKUP_REPORT_MISS liamsmith827
2026-11-16 20:27 ` [PATCH net-next v5 2/4] ipv4: restrict on-link fallback to lookup misses liamsmith827
2026-11-18 23:28   ` netdev-bot+sashiko [this message]
2026-11-16 20:27 ` [PATCH net-next v5 3/4] selftests: net: test restricted on-link fallback liamsmith827
2026-11-18 23:28   ` netdev-bot+sashiko
2026-11-16 20:27 ` [PATCH net-next v5 4/4] ipv4: replace obsolete routing comment liamsmith827
2026-11-18 23:28   ` netdev-bot+sashiko
2026-11-17 10:56 ` [PATCH net-next v5 0/4] ipv4: restrict on-link fallback to lookup misses Ido Schimmel

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=179504450812.3136.16231358596487999009@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=liamsmith827@grapheneos.org \
    --cc=liamsmith827@proton.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.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