From nobody Thu Aug 29 13:51:09 2024 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 4WvjNs6ff9z5PTf8; Thu, 29 Aug 2024 13:51:09 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WvjNs647Yz4ftS; Thu, 29 Aug 2024 13:51:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724939469; 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=smfGShyH+mGQnhM/S0HzA9p4rOENWIvfXJWjZkTGUN0=; b=ak9ADn+czsIu0uNSEVCoCJq7oxQJXdmLyAr21475Dw5bT7GV+DIlz0tyrBUYzGWMa4Yfls lG7Sl9BUJ55ltIaZY1T80JUkPoQOxvNfI3rThBrQ9+a0hQZxEfiSFsmKyzNgTWQBWGaaf/ AJBXXofP8+h86rkZtZoVJm7UheB4YuKrSjjUF/oFV9bRn6tZdY7nTPXLoXqr4ERWWHHxdB uPDN1mb64OxkCFvRCGC8MP6gMimD73XuXJPntq1wWC+6QRSa96v2izKuRIdr2QOkfPV8m+ 2f561qJacOWVFDG4P/6M6UZsq1+YVSnnTArHgIRnyx6mP3CBd6idK0Q3fao2Xg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724939469; a=rsa-sha256; cv=none; b=FOufqgi/5WjChXV9JWCs8/SRXxslW3invDB5DmXu7g1tCRrls0D02wgbWNLuMUfamNTXR2 7wFwWj64n/H865GbmMoyINebWrguVbx75P5vgo8RkGvcZTeAlL/SpPsRbCKObiUiHu4uqn uM6Zej+dizxMGq7fC0D5rP3qjJwtlTQENZJ+/bd0R7Bc8EqXzjqIpQSw8Wqj+ek/JhlufI afHMyIBEIbEc7lOnlPwq/FOlmDQkRblfuEep9QRaHkg6kfzSqVo0vSZlaSLWacOlk/OPqt pv9550SNVkgfZtOknqCBkqbzO2jMdyQGCRzw5OxACa+m4ATrRsKVeqTvmLjS0w== 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=1724939469; 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=smfGShyH+mGQnhM/S0HzA9p4rOENWIvfXJWjZkTGUN0=; b=KVC5QpQD9XsN3Y3Q7wk5y4bzxt8ZxIdX1V9hiDi4ztdJ+e4SFjnafDp+HkpvMSUhd7wz2M c6w1Xrm7WieGspEyQcifAhpyH4+e9WA5RyQZkgo/Kntuj2tXJa7ahqyf0IG2gM5tqP4IRT oz7QfVqCUzYe1WTuJfz7P3WwK9aLYtoAKCs9TiCoKV+MYhK6rNF8GVbQTUJNK93MNouC8k WCKMEDAn22ij/hh8eb2KDkf7Z0dEYd9PsWkxmF7PpAZ9aeo+P35ePm+nljzuBzdR+Hj26X /XCpN3lpSt9N2Ioj1zJTDK5Y6wiKX/qr4sB8XDcojobJxJbr/Of416q3t6wJDg== 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 4WvjNs5hGKzKL4; Thu, 29 Aug 2024 13:51:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47TDp9EH052303; Thu, 29 Aug 2024 13:51:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47TDp9fZ052300; Thu, 29 Aug 2024 13:51:09 GMT (envelope-from git) Date: Thu, 29 Aug 2024 13:51:09 GMT Message-Id: <202408291351.47TDp9fZ052300@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 0c605af3f9d9 - main - netinet: Explicitly disallow connections to the unspecified address 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0c605af3f9d9e66be6af0a3bbc36dbedc5dfe516 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=0c605af3f9d9e66be6af0a3bbc36dbedc5dfe516 commit 0c605af3f9d9e66be6af0a3bbc36dbedc5dfe516 Author: Mark Johnston AuthorDate: 2024-08-29 13:11:15 +0000 Commit: Mark Johnston CommitDate: 2024-08-29 13:11:15 +0000 netinet: Explicitly disallow connections to the unspecified address If the V_connect_ifaddr_wild sysctl says that we shouldn't infer a destination address, return an error. Otherwise it's possible for use of an unspecified foreign address to trigger a subsequent assertion failure, for example in in_pcblookup_hash_locked(). Similarly, if no interface addresses are assigned, fail quickly upon an attempt to connect to the unspecified address. Reported by: Shawn Webb MFC after: 2 weeks Reviewed by: zlei, allanjude, emaste Differential Revision: https://reviews.freebsd.org/D46454 --- sys/netinet/in_pcb.c | 2 ++ sys/netinet6/in6_pcb.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 70ddd581895f..6ea197cf68d8 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1336,6 +1336,8 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr_in *sin, faddr = satosin(&CK_STAILQ_FIRST( &V_in_ifaddrhead)->ia_broadaddr)->sin_addr; } + } else if (faddr.s_addr == INADDR_ANY) { + return (ENETUNREACH); } if (laddr.s_addr == INADDR_ANY) { error = in_pcbladdr(inp, &faddr, &laddr, cred); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 098b4e50483c..501434f2fac6 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -368,7 +368,10 @@ in6_pcbladdr(struct inpcb *inp, struct sockaddr_in6 *sin6, */ if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) sin6->sin6_addr = in6addr_loopback; + } else if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { + return (ENETUNREACH); } + if ((error = prison_remote_ip6(inp->inp_cred, &sin6->sin6_addr)) != 0) return (error);