Article View: linux.kernel.netdev
Article #6813Re: [PATCH net 3/7] ovpn: reject UDP remotes incompatible with socket family
From: netdev-bot+sashiko
Date: Fri, 23 Oct 2026 12:17
Date: Fri, 23 Oct 2026 12:17
143 lines
13184 bytes
13184 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In this commit, ovpn_nl_udp_remote_compatible()
(drivers/net/ovpn/netlink.c) checks sk->sk_family andβ¦
- [Low] The concern says the new rejection in
ovpn_nl_udp_remote_compatible() (AF_INET6 socket + ipv6_only_sock() +β¦
- [Low] The concern says the NULL inet6_sk(sk) dereference the commit
message describes is still reachable through the RX float path.
--
ovpn: reject UDP remotes incompatible with socket family
This commit adds ovpn_nl_udp_remote_compatible(). It rejects UDP remotes
that the attached socket cannot use when a peer is created or modified
over netlink: an IPv6 remote on an AF_INET socket, or an IPv4 remote on an
IPv6-only socket. The remote endpoint is now parsed once in the new/set
paths and passed to ovpn_nl_peer_modify(), and the commit message notes
that the transmit path still has to re-check the socket later.
> diff --git a/drivers/net/ovpn/netlink.c b/drivers/net/ovpn/netlink.c
> index 1af7e0e624ba6..bf27a7a89f76b 100644
> --- a/drivers/net/ovpn/netlink.c
> +++ b/drivers/net/ovpn/netlink.c
[ ... ]
> @@ -383,12 +385,45 @@ static int ovpn_nl_peer_modify(struct ovpn_peer *peer, struct genl_info *info,
> return ret;
> }
>
> +/**
> + * ovpn_nl_udp_remote_compatible - check if a UDP socket can use a remote
[ ... ]
> +static int ovpn_nl_udp_remote_compatible(const struct sock *sk,
> + const struct sockaddr_storage *remote,
> + struct netlink_ext_ack *extack)
> +{
> + const unsigned short sock_family = READ_ONCE(sk->sk_family);
[Severity: Low]
This check reads sk->sk_family and ipv6_only_sock(sk) once, without
lock_sock(), while the PEER_NEW/PEER_SET request is handled. In
ovpn_nl_peer_set_doit() it runs under rcu_read_lock(), and that lock is
dropped before ovpn_nl_peer_modify() installs the new bind.
The commit message says:
The transmit path therefore still has to re-check socket/remote
compatibility before sending.
At this commit, ovpn_udp_output() still picks ovpn_udp4_output() or
ovpn_udp6_output() based only on bind->remote.in4.sin_family. A later
IPV6_V6ONLY or IPV6_ADDRFORM change is therefore not caught on TX.
Is this patch meant to be complete on its own for stable? The next patch
in the series, "ovpn: recheck UDP socket family before transmit", adds the
sock_family check in ovpn_udp_output() and closes this gap. It looks like
the two patches need to be backported together.
> +
> + if (sock_family == AF_INET && remote->ss_family == AF_INET6) {
> + NL_SET_ERR_MSG_FMT_MOD(extack,
> + "UDP socket is IPv4 but remote is IPv6");
> + return -EAFNOSUPPORT;
> + }
[Severity: Low]
This rejects an IPv6 remote on an AF_INET socket when the remote comes from
netlink. Can the same mismatched bind still be installed through the RX
float path, which does not go through this helper?
drivers/net/ovpn/io.c:ovpn_recv() {
...
if (sock && sock->sk->sk_protocol == IPPROTO_UDP)
/* check if this peer changed local or remote endpoint */
ovpn_peer_endpoints_update(peer, skb);
...
}
ovpn_peer_endpoints_update() updates the bind from the received packet and
does not look at the socket family. If the bind becomes AF_INET6 on a peer
whose socket is AF_INET, the next transmit would take this path:
ovpn_udp_output()
ovpn_udp6_output()
ip6_dst_lookup_flow(sock_net(sk), sk, &fl, NULL)
That path reaches the inet6_sk(sk) NULL dereference described in the
commit message.
At the end of the series, "ovpn: recheck UDP socket family before transmit"
covers this case. Before calling ovpn_udp6_output(), ovpn_udp_output() now
rejects AF_INET6 binds when sock_family != AF_INET6. With that patch, the
only remaining effect is that the floating peer is deleted with a transport
error.
Without that patch, does this commit alone prevent the crash it describes?
> +
> + if (sock_family == AF_INET6 && ipv6_only_sock(sk) &&
> + remote->ss_family == AF_INET) {
> + NL_SET_ERR_MSG_FMT_MOD(extack,
> + "UDP socket is IPv6-only but remote is IPv4");
> + return -EAFNOSUPPORT;
> + }
[Severity: Low]
This isn't a bug, but I have a question about this part of the commit
message:
An IPv4 UDP socket cannot be used with an IPv6 remote endpoint, and an
IPv6-only UDP socket cannot send to an IPv4 remote endpoint.
At this commit, ovpn_udp4_output() gets the route with
ip_route_output_flow(sock_net(sk), &fl, sk) and does not check
ipv6_only_sock(sk). So ovpn's own TX path would still send in this
configuration.
What actually makes the configuration unusable is the receive side, since
compute_score() in net/ipv4/udp.c skips IPv6-only sockets. The regular
udpv6_sendmsg() behaviour for v4-mapped destinations points the same way.
The next patch in the series adds the matching ipv6_only_sock() check in
ovpn_udp_output(), so the netlink and TX rules agree by the end of the
series. Since this patch rejects a configuration that used to be accepted,
would it be worth making the reasoning clearer here?
> +
> + return 0;
> +}
[ ... ]
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261022121606.732029-2-antonio%40openvpn.net
Technical Details
Message-ID:
<179275784657.3134.14079628149115069764@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351063-linux-kernel-netdev=dewy.ruReferences:
<20261022121606.732029-4-antonio@openvpn.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351063-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 3/7] ovpn: reject UDP remotes incompatible with socket family Date: Fri, 23 Oct 2026 12:17:26 +0000 Organization: Usenet Network Message-ID: <179275784657.3134.14079628149115069764@kernel.org> References: <20261022121606.732029-4-antonio@openvpn.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="494531"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:X70GyRz6HQ/O9U6asY93Oh9S3Gw= sha256:hzWrTUw3A+4QMnwWh3l84NJrOeC/O0esQrJfzHmmWM8= sha1:Ve6Q9BJBIFf/RDsQAKBTXRFzFT0= sha256:XmoLpR0jI4XoVxAEG/53GDBWINxX8fm1teYzqVl6Dis= 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 3905A111498; Fri, 23 Oct 2026 15:20:58 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.838 X-Spam-Status: No, score=-3.838 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.339, 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 qsiioK1fAVf8; Fri, 23 Oct 2026 15:20:54 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-351063-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 859E4111489; Fri, 23 Oct 2026 15:20:45 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id C99FF60F11C; Fri, 23 Oct 2026 12:18:17 +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=1792757849; b=l9EP7ALiSZtS5POxGIi//YX/g5GB6d8Ji/q54XaPL/cag04WYoSiUfUwpmMk+YfgqlBm VT8u5Kb0uhdlukhPR/RWL40NV2uxPT3mq9LbOAIuRGlbYU9Adil9xONN/UkI7AaZjG3Yt SKjK++CnlNmACWyFcF87lmCY2WFhBMp2w/CoNA6ZfQnCr9KzcKUBRQ33wN4Ulj7iyGq6C NeTlzuVRgyoycgq03ukGHDmbgYQmipspJiVUOPWX5j+w+mUIfYU2hv1TxGvjJAMv0n1qt Ce0Yj9iDm0L54LI7wZD+ArbNOh9Ot6bNeR245e1BNXgygGgDH6XkXFdQWMqY7vlYb9g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792757849; 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=lxYi6lYgPezmPFyKxvqAdM5ywA+AGWlloT6U0eWiBso=; b=eqMGLm3XRPVJt5+PPJIOGZHgZ06Wbsqds197/xgtOym4v5JlScqhkQ0kN+yh5Cky0NQe lPDi+XjQqVP+XHysn9Hq1OwFZuOKQNX4b70iT2v6SF0WjiAv5QQI69NRdJf/Fl7Z654Ei 2c7l7c98+c2VplY/unKjuGoxh4CIOkO/cdwkedc97rRc4vXobtV7BUhmS7ILg+pr8Bi1p brpxWS5XMMD91ghvrG7lIeF7UwwAIYvcLThc4lBmIe7BvRNiv/VIo89iiUUCl4R7bGJgB buDJle+K0pizpkroYP2o4ZEJpuXImAztI1lcXcMfXElWs3sR/5qAoWfndfw57BxLrNw== 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=dMn1x0lY; 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 38717606A328; Fri, 23 Oct 2026 12:17:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dMn1x0lY 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=1792757848; b=VLwSZWvr5Tc2mcINT/SWHeZEukNtlzoDzL6X4jJ0K/Ehur1pi9XYigsW+Yoj2UqDYnej 2E/tzXUKdmymC01ar/t0cQx4fbwDx3YyopYvqXjZ3H0LIQpPmQFHskVkvxnwdd5Ph56P1 LCNBNBeBKDx67QOTvWQ5uyBfNe69si9JFRE1kI65HRp2tDw/6dBdTXSv/ETUFtCOA4O0R HvQ+WfLTfv3aC/ZPSBVSiKfeziUYajOXBTjEt8idI5U4QgKc/jGrAAgEHCI5RllE2dKJL N5z8tFV1OPZgNzk4SnHHhvu4wCp2D+cCVlQ5G5rmMymByoUhKMjqzatBh5/rztQ5rLQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792757848; 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=lxYi6lYgPezmPFyKxvqAdM5ywA+AGWlloT6U0eWiBso=; b=ysoiAZTRe/UyZLSwX1M9z7W3tpTlTBXPsZYxaF6hTvW6ysqD0uCIfJ5AubLcTs8wQ3i7 XSSJVz+VvzHBXRm8pDn4iLJIYXj2pXzjC+eWY0lSj5/TpSeRb4XctMljPm4uSPE8Jm+F1 PSHFhbjnrv6l1gyInVLznCqDbxvfDfkaVscCSqNoCF0VfMHk/mNGMlx2SJcIwwZ/twTfr EsFCNX7zilf8WnlcyKRTEuQFAqcURpJ2HJUOAUG8rQs/+K6+VYNRMr5YIc2ruLiFTvuRS klsQ8YA0Vje2cqaavjZGJ+fIOegKdjPQC0w+avIAEAr1EnOfYV2UgsDPZdrc2Fq8w+A== 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=dMn1x0lY; 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 040D9606A323; Fri, 23 Oct 2026 12:17:27 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F4FC1F01825; Fri, 23 Oct 2026 12:17:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792757847; bh=lxYi6lYgPezmPFyKxvqAdM5ywA+AGWlloT6U0eWiBso=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dMn1x0lYN4tEAqwyM4/kfiA9V3zPfVzDUcgWvwlJNIQAdJgUj8LnvDw0gFPXAikEb nClGqDqrqXx+bVJpAJSxC18xROpnfUs9EhJfmOy65G0bRd4Y5KEoTIUX9wNTpSWB8L ZUGD2s4Suz6npLUXH9mbxJQb97pMYucDOG47d97B0Uil+WiglZll5oehkSTb73eYMM Sc4UbK0VKaf49QkffjNHK/HRlLccObzR4ml7Ckt7pOU52Hft6li3HJXqP9mxhXmu0+ baCGDfb1hkf2rqXyp59bopzr4hyxT9GoJQdWL0jKat55txhm8K5WJ8q0z+pLvSeh3Z cRdpTkc11le7w== X-Cc: netdev@vger.kernel.org, ralf@mandelbit.com, sd@queasysnail.net, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, stable@vger.kernel.org X-In-Reply-To: <20261022121606.732029-4-antonio@openvpn.net> X-sashiko-severity: Low 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