From nobody Fri Sep 20 11:39:57 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 4X99RK70bFz5WdnD; Fri, 20 Sep 2024 11:39:57 +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 4X99RK5rQdz4lPl; Fri, 20 Sep 2024 11:39:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726832397; 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=KjPAB+LK/oNSQPHPB3HI2mfB+Ey4rqH6rWy1HTO2VBs=; b=vL8eIdOOtUtfylk2Q12ZQ97CIDL8mOJuYMz53zxDpql1KbFZzT0TEeRzs4oUJMBLvqyXtz TDTy35P5IBUnwl9u44s9+5cK+uYaSHHkm/CQYEKtTTmIvCjZVzpqUnd+OmpvvD9LvpNJEY bYpl5APIxlxpoZG6MowNTT2hbUHXU+Abj5+DhTargLwBvunZk6dvaLbhrMfl2KzUNczI0D UMVYjmuoATSqLLsd1s457r2jhNN5bxGNYRmt68eZPNLjQeCoRFXykLzP4BoKAMrc2HG8RH 48gWDCo5J1dDAJ9ynmmx5fthNISMjevYskZODnK+F+GTy72jt8guz5hKgKfHGw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726832397; a=rsa-sha256; cv=none; b=Xq22H7K2dYt1FPIh+Snrxh67Z+MAqhWLMLOHvhFvlmNjOe6qgdiyDzmNjunsqyGgIBPhF/ nxq+BksYJX2+a3tESnAxZn0yCmgrB8cPemVNv+Rgcz//e6FYRsfCk+xAP6t5z6mY4+2zOz 2BDPlVaGhrFem3Kj2dfs4iWPQWbZQAiaRKIcWY84zCNWPN88EydTaCye6IJti8UhSqDSOR VD4ecgGL5CCIx+0bVCZAg4NJ6EEqdkM4w250ZdSudcVqFoMlCP4k3K5Fv0nGr7AtOWcB7u VupPiXjg0bki9iqAh5yV87PqF5Sk/eXCAfrd8RL8UdILPTXQ3K6rF8EvLDiPlA== 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=1726832397; 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=KjPAB+LK/oNSQPHPB3HI2mfB+Ey4rqH6rWy1HTO2VBs=; b=KUwyBTaqPMxEB39UBdFaF0fYt0NaKNhInzp4aBhGwsCjdtaQT5hAqePNonE7vjlecsyQds AtKYdzXplDXKWaGOhV+daLzPldf9AStpCXeAaaWyd3Ea2T0X63lfE8pcyQqs4F1xcR4MkZ q9SqZiU9XKYSaOErOm7AcrmWrB3WD43v0pBH83ov7j/TdsHy5F1FgWIiVKdB87RM4my0h/ cT1kbYFsTJWrgo7YmOFyu1pu97w1A82hjzyKfaGYTmQBFxGo5XVOsqv8xDdExF/hBD65h5 RPiducgqaQRY1wAsZx6Vk/6e/rFoB4lGvg77hOjDepJLjymGWrikPiTdwp91kw== 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 4X99RK5QB4znj6; Fri, 20 Sep 2024 11:39:57 +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 48KBdvNp004404; Fri, 20 Sep 2024 11:39:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48KBdv6b004401; Fri, 20 Sep 2024 11:39:57 GMT (envelope-from git) Date: Fri, 20 Sep 2024 11:39:57 GMT Message-Id: <202409201139.48KBdv6b004401@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 59f3eb3b71d5 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 59f3eb3b71d5df21882ed95d99ac10911f305b81 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=59f3eb3b71d5df21882ed95d99ac10911f305b81 commit 59f3eb3b71d5df21882ed95d99ac10911f305b81 Author: Mark Johnston AuthorDate: 2024-08-29 13:11:15 +0000 Commit: Mark Johnston CommitDate: 2024-09-20 11:39:16 +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 (cherry picked from commit 0c605af3f9d9e66be6af0a3bbc36dbedc5dfe516) --- 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 28cd64ccbde6..f6904690deab 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1338,6 +1338,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 8046e0fa530d..f7f2ea0b8699 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -370,7 +370,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);