From nobody Fri Oct 13 20:16:42 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S6d7t3kj3z4wk1b; Fri, 13 Oct 2023 20:16:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S6d7t3KNfz4cqW; Fri, 13 Oct 2023 20:16:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697228202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wPzBNMjk3mWYn1HEaLCiVUoskbP9gtdk9ihsazINPjo=; b=DAD6qFhInWTk9GxxVmli+kNEnd57+xahH+R8w7CM95dcIcUHUBcaXG6OLHx3v72aDG6XVq KgdObgJTk77Ys0+TIKF5YupPKsC9Qprv1LVUgoaPAa395gYbrwmJSOPIxIjaGl9NqXcC9G smaWex7zPNLDMx+bT/Fd2xwJWDPRIXEAO0f0zokaLK01e5uti8KuqlQXilGuZJ6ZSrHVH4 ShXc0Njl5xbw78pSCWte6kMH9MKQ++DmxYodzozxhu2nkSnmrm2BbxzVcxAUJSoXAKQT9x x1mu0FuoBpzY+JFRsQBiLkSK+6Jp5tSVAa7ItQtp0/Ec2uWlXZdQRoobWYzAYw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697228202; a=rsa-sha256; cv=none; b=I48tEM+xSP8+ftiOyKgT55zknNr9b8k9AZbggJRltbhgYoWV6q9v+kdTnB33pD+kE77qu0 m4Wsqc/J8GUiHrxwsUrg2H3chT0dEsrH4pzT52NWxFX8UfsFsGqczlzFlVxt9FrsNMfBBJ MuurpPKo7FrYQBY+qaY3vwqpXomG3CzC9UWvH4vK+OQfREaKtptpG6A7pslzihjYg8SFeN 93f+Q/kX9scgUk5pB24uFyUoGxuSd8OC69+2a+m0Z5G//MffPT2wOE6EftIOYNyoyBilbb A/UhY0Ws8HHKSNekmuShmfzg3yEx7ugRGIf8yYkFcfHWvRMHGfpZT8ixT73Lyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697228202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wPzBNMjk3mWYn1HEaLCiVUoskbP9gtdk9ihsazINPjo=; b=tuxsqGPnxXazMOM0Xpd2sewuFtrAXRL4oBrNOHErH3dZBoE5vcKHnoCcBXt6m1gzBcq3bk LudH+Jj6pxg4ddeJXHHBuVmNOevm6rnNmhn4tYB9HbcbeDoaiC7U4VNYYX5QxqAxpVkwFh Sx7+IC9W7Q6E3S30tol8Jt4e+/hnh9DOvIsgnmGk3sVz2zD/1F+DYYwOF1KoVMmeC5ewHO ZTJCWZ2+wsBOkZS+DdJFZTIT89UulYiM4auxRIHKAialdQZTY/iBEblAWsw1ieudNE5Nf7 0kPwzcAdMKvty7oT+Gu6SJreNtp/ZRCZLZlj+PBUfnYIL9MKmUVM109Mt3pUzA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S6d7t26T2z11Nn; Fri, 13 Oct 2023 20:16:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39DKGgWb065690; Fri, 13 Oct 2023 20:16:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39DKGgUC065687; Fri, 13 Oct 2023 20:16:42 GMT (envelope-from git) Date: Fri, 13 Oct 2023 20:16:42 GMT Message-Id: <202310132016.39DKGgUC065687@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 8209af15a699 - stable/14 - udp: fix sending of IPv4-mapped addresses List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 8209af15a6994d52276be05380e0c0b7ae117cea Auto-Submitted: auto-generated The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=8209af15a6994d52276be05380e0c0b7ae117cea commit 8209af15a6994d52276be05380e0c0b7ae117cea Author: Michael Tuexen AuthorDate: 2023-10-07 13:56:00 +0000 Commit: Michael Tuexen CommitDate: 2023-10-13 20:13:44 +0000 udp: fix sending of IPv4-mapped addresses The inp_vflags field must be adjusted during the call of in_pcbbind_setup(). This is consistent with the other places in the code, but not elegant at all. PR: 274009 Reported by: syzbot+81ccc423a2737ed031ac@syzkaller.appspotmail.com Reported by: syzbot+c8e3dac881bba85bc029@syzkaller.appspotmail.com Reviewed by: markj, rrs, rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D42031 (cherry picked from commit abca3ae7734f664ee9c5edc7a9d3a17e29180bdb) --- sys/netinet/udp_usrreq.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 70d738bf2108..cbda7f536262 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1050,7 +1050,7 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, int cscov_partial = 0; int ipflags = 0; u_short fport, lport; - u_char tos; + u_char tos, vflagsav; uint8_t pr; uint16_t cscov = 0; uint32_t flowid = 0; @@ -1092,7 +1092,8 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, * pcb hash. */ if (sin == NULL || - (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0)) + (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0) || + (flags & PRUS_IPV6) != 0) INP_WLOCK(inp); else INP_RLOCK(inp); @@ -1203,10 +1204,17 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, error = EINVAL; goto release; } + if ((flags & PRUS_IPV6) != 0) { + vflagsav = inp->inp_vflag; + inp->inp_vflag |= INP_IPV4; + inp->inp_vflag &= ~INP_IPV6; + } INP_HASH_WLOCK(pcbinfo); error = in_pcbbind_setup(inp, &src, &laddr.s_addr, &lport, td->td_ucred); INP_HASH_WUNLOCK(pcbinfo); + if ((flags & PRUS_IPV6) != 0) + inp->inp_vflag = vflagsav; if (error) goto release; } @@ -1249,9 +1257,16 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, inp->inp_lport == 0 || sin->sin_addr.s_addr == INADDR_ANY || sin->sin_addr.s_addr == INADDR_BROADCAST) { + if ((flags & PRUS_IPV6) != 0) { + vflagsav = inp->inp_vflag; + inp->inp_vflag |= INP_IPV4; + inp->inp_vflag &= ~INP_IPV6; + } INP_HASH_WLOCK(pcbinfo); error = in_pcbconnect_setup(inp, sin, &laddr.s_addr, &lport, &faddr.s_addr, &fport, td->td_ucred); + if ((flags & PRUS_IPV6) != 0) + inp->inp_vflag = vflagsav; if (error) { INP_HASH_WUNLOCK(pcbinfo); goto release;