From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385993; b=i+u6ZYQfOMRbKuc2OrF3vEnOd865+1ocMh2Po2/yHcs48GsEUPrMp6CEfv9se0d4pjLG glK9j7XwYBOtFkgVrZKrXutzZSyAtLtsPrSUy4dl1XNbdmKdgDO00UiN228o/b1TnBMsN A0GktuymLodwy8pmSJ5xy4OQjHVdNXeDx7jtas9RNXRzEqTdPBlNcqjyiiwNRufVGctq0 oQUHFrLf267NJT4xKUWmADv43h+JpFT68px497Ps3+ND5r4b8L9qiLXnJNl9i8qyIPAMx ijwypAg8d1z4tB+GoFzBqCyYD09B2ZWsLkvHdycIPC/ui9p2q8jmsmuuK2ovLDSxrcw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385993; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=ufeGN+UX4X04pkxwiauCkrxpcH/QtiYC8W2A6zSJpPw=; b=Z/pvhNpkceupdE1NEEwmQw0KSz8ZqumOxxg5QVqAM0G9YlknqaMSeP3d2maG3+3yHj/E oywbFtQm5cGJIXZvF8s3+zqyBL6OZp7JA6EGVRu5dSs3jiSPO9d8OIlp8yhTdC//bsZHn pciqPdP4pbFiwg50SMt75/yAr52V6o6rRdOHzBZ9WMtUTngGDNrnY2syDbcNMEN5rzwjZ RTrkfgdk4K1dSw94X54qKKWG8x1OqgsxOYyqHSj8fqhuzCH8oRsD6lB0cVKDJh9shL0bz sn/w49rk72N1KAztB8XHmQPRcHYLLxg+0od+UiMIlKwJzEEhuNM8vtnOyZiPN3+6TWg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Y+3Kc70u; arc=none smtp.remote-ip=100.103.45.18 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 B2FDF606A322; Fri, 4 Dec 2026 12:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Y+3Kc70u Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DFE61F000CE; Fri, 4 Dec 2026 12:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385993; bh=ufeGN+UX4X04pkxwiauCkrxpcH/QtiYC8W2A6zSJpPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y+3Kc70u7lcl4EsZlVVqNK1SIvWKPe8bZ3nFxKq790oD5G1tieV/44vGXFhq9jcam 693bxdDubSIHt+ezaT4L7dp/41k3AgmvunGP3tNiVJUPL4rYMhUatpwvrW+7Zl7WQ/ W5PUqiLuAtXShmJpdUK8uGKe3EOEU90oSZsDyi50= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daehyeon Ko <4ncienth@gmail.com>, Hyunwoo Kim , Kuniyuki Iwashima , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0763/1167] ipv6: Remove IPV6_ADDRFORM. Date: Fri, 4 Dec 2026 19:03:10 +0900 Message-ID: <20261204100721.956250583@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit 31c5ea8a3296e1486ac34bccea452bfe8c0bb1f9 ] Recently, IPV6_ADDRFORM has received many AI-driven bug reports. Fixing them properly would needlessly churn the fast paths in TCP and UDP. IPV6_ADDRFORM was initially introduced in RFC 2133 in 1997, but only two years later, it was removed from RFC 2553 in 1999. In 2026, modern applications natively support dual-stack sockets; notably, systemd's socket activation does not use IPV6_ADDRFORM. Also, getsockopt(IPV6_ADDRFORM) can be replaced with SO_DOMAIN. Let's remove IPV6_ADDRFORM. Later, we can remove sk->sk_prot_creator and revert commit c26c192c3d48 ("udp: properly deal with xfrm encap and ADDRFORM"). Reported-by: Daehyeon Ko <4ncienth@gmail.com> Closes: https://lore.kernel.org/netdev/20260902010408.1057857-1-4ncienth@gmail.com/ Reported-by: Hyunwoo Kim Closes: https://lore.kernel.org/netdev/20260824033331.1084971-1-imv4bel@gmail.com/ Signed-off-by: Kuniyuki Iwashima Link: https://patch.msgid.link/20260904033543.2635540-3-kuniyu@google.com Signed-off-by: Jakub Kicinski [ Hyunwoo Kim: Keep the 6.6.y inet_accept() signature and remove UDP-Lite handling from the IPV6_ADDRFORM set/get branches. ] Signed-off-by: Hyunwoo Kim Signed-off-by: Sasha Levin --- include/linux/net.h | 2 +- net/core/sock.c | 4 +- net/ipv4/af_inet.c | 3 -- net/ipv6/af_inet6.c | 4 -- net/ipv6/ipv6_sockglue.c | 95 ---------------------------------------- 5 files changed, 2 insertions(+), 106 deletions(-) diff --git a/include/linux/net.h b/include/linux/net.h index c9b4a63791a45..45bd92b817ff1 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -123,7 +123,7 @@ struct socket { struct file *file; struct sock *sk; - const struct proto_ops *ops; /* Might change with IPV6_ADDRFORM or MPTCP. */ + const struct proto_ops *ops; /* Might change with MPTCP. */ struct socket_wq wq; }; diff --git a/net/core/sock.c b/net/core/sock.c index 9c04591a1bedc..0aab349934fd8 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -768,7 +768,7 @@ bool sk_mc_loop(const struct sock *sk) sk = sk_const_to_full_sk(sk); if (!sk) return true; - /* IPV6_ADDRFORM can change sk->sk_family under us. */ + switch (READ_ONCE(sk->sk_family)) { case AF_INET: return inet_test_bit(MC_LOOP, sk); @@ -3736,7 +3736,6 @@ int sock_common_getsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ return READ_ONCE(sk->sk_prot)->getsockopt(sk, level, optname, optval, optlen); } EXPORT_SYMBOL(sock_common_getsockopt); @@ -3763,7 +3762,6 @@ int sock_common_setsockopt(struct socket *sock, int level, int optname, { struct sock *sk = sock->sk; - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ return READ_ONCE(sk->sk_prot)->setsockopt(sk, level, optname, optval, optlen); } EXPORT_SYMBOL(sock_common_setsockopt); diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index dd4e334a47886..8d75cee4232d4 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -574,7 +574,6 @@ int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, if (addr_len < sizeof(uaddr->sa_family)) return -EINVAL; - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ prot = READ_ONCE(sk->sk_prot); if (uaddr->sa_family == AF_UNSPEC) @@ -776,7 +775,6 @@ int inet_accept(struct socket *sock, struct socket *newsock, int flags, struct sock *sk1 = sock->sk, *sk2; int err = -EINVAL; - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ sk2 = READ_ONCE(sk1->sk_prot)->accept(sk1, flags, &err, kern); if (!sk2) return err; @@ -860,7 +858,6 @@ void inet_splice_eof(struct socket *sock) if (unlikely(inet_send_prepare(sk))) return; - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ prot = READ_ONCE(sk->sk_prot); if (prot->splice_eof) prot->splice_eof(sock); diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index e009cdb699d74..e329473df4e53 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -442,7 +442,6 @@ int inet6_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len) const struct proto *prot; int err = 0; - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ prot = READ_ONCE(sk->sk_prot); /* If the socket has its own bind function then use it. */ if (prot->bind) @@ -581,7 +580,6 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) case SIOCSIFDSTADDR: return addrconf_set_dstaddr(net, argp); default: - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ prot = READ_ONCE(sk->sk_prot); if (!prot->ioctl) return -ENOIOCTLCMD; @@ -652,7 +650,6 @@ int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) if (unlikely(inet_send_prepare(sk))) return -EAGAIN; - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ prot = READ_ONCE(sk->sk_prot); return INDIRECT_CALL_2(prot->sendmsg, tcp_sendmsg, udpv6_sendmsg, sk, msg, size); @@ -671,7 +668,6 @@ int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, if (likely(!(flags & MSG_ERRQUEUE))) sock_rps_record_flow(sk); - /* IPV6_ADDRFORM can change sk->sk_prot under us. */ prot = READ_ONCE(sk->sk_prot); err = INDIRECT_CALL_2(prot->recvmsg, tcp_recvmsg, udpv6_recvmsg, sk, msg, size, flags, &addr_len); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 48fe3eb42f016..c6908912024c6 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -443,93 +443,7 @@ int do_ipv6_setsockopt(struct sock *sk, int level, int optname, rtnl_lock(); sockopt_lock_sock(sk); - /* Another thread has converted the socket into IPv4 with - * IPV6_ADDRFORM concurrently. - */ - if (unlikely(sk->sk_family != AF_INET6)) - goto unlock; - switch (optname) { - - case IPV6_ADDRFORM: - if (optlen < sizeof(int)) - goto e_inval; - if (val == PF_INET) { - if (sk->sk_type == SOCK_RAW) - break; - - if (sk->sk_protocol == IPPROTO_UDP || - sk->sk_protocol == IPPROTO_UDPLITE) { - struct udp_sock *up = udp_sk(sk); - if (up->pending == AF_INET6) { - retv = -EBUSY; - break; - } - } else if (sk->sk_protocol == IPPROTO_TCP) { - if (sk->sk_prot != &tcpv6_prot) { - retv = -EBUSY; - break; - } - } else { - break; - } - - if (sk->sk_state != TCP_ESTABLISHED) { - retv = -ENOTCONN; - break; - } - - if (ipv6_only_sock(sk) || - !ipv6_addr_v4mapped(&sk->sk_v6_daddr)) { - retv = -EADDRNOTAVAIL; - break; - } - - __ipv6_sock_mc_close(sk); - __ipv6_sock_ac_close(sk); - - if (sk->sk_protocol == IPPROTO_TCP) { - struct inet_connection_sock *icsk = inet_csk(sk); - - sock_prot_inuse_add(net, sk->sk_prot, -1); - sock_prot_inuse_add(net, &tcp_prot, 1); - - /* Paired with READ_ONCE(sk->sk_prot) in inet6_stream_ops */ - WRITE_ONCE(sk->sk_prot, &tcp_prot); - /* Paired with READ_ONCE() in tcp_(get|set)sockopt() */ - WRITE_ONCE(icsk->icsk_af_ops, &ipv4_specific); - WRITE_ONCE(sk->sk_socket->ops, &inet_stream_ops); - WRITE_ONCE(sk->sk_family, PF_INET); - tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); - } else { - struct proto *prot = &udp_prot; - - if (sk->sk_protocol == IPPROTO_UDPLITE) - prot = &udplite_prot; - - sock_prot_inuse_add(net, sk->sk_prot, -1); - sock_prot_inuse_add(net, prot, 1); - - /* Paired with READ_ONCE(sk->sk_prot) in inet6_dgram_ops */ - WRITE_ONCE(sk->sk_prot, prot); - WRITE_ONCE(sk->sk_socket->ops, &inet_dgram_ops); - WRITE_ONCE(sk->sk_family, PF_INET); - } - - /* Disable all options not to allocate memory anymore, - * but there is still a race. See the lockless path - * in udpv6_sendmsg() and ipv6_local_rxpmtu(). - */ - np->rxopt.all = 0; - - inet6_cleanup_sock(sk); - - module_put(THIS_MODULE); - retv = 0; - break; - } - goto e_inval; - case IPV6_V6ONLY: if (optlen < sizeof(int) || inet_sk(sk)->inet_num) @@ -1124,15 +1038,6 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname, if (copy_from_sockptr(&len, optlen, sizeof(int))) return -EFAULT; switch (optname) { - case IPV6_ADDRFORM: - if (sk->sk_protocol != IPPROTO_UDP && - sk->sk_protocol != IPPROTO_UDPLITE && - sk->sk_protocol != IPPROTO_TCP) - return -ENOPROTOOPT; - if (sk->sk_state != TCP_ESTABLISHED) - return -ENOTCONN; - val = sk->sk_family; - break; case MCAST_MSFILTER: if (in_compat_syscall()) return compat_ipv6_get_msfilter(sk, optval, optlen, len); -- 2.53.0