From nobody Tue May 30 19:30:08 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 4QW2Xx0XSKz4Y2KW; Tue, 30 May 2023 19:30: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QW2Xx0083z494P; Tue, 30 May 2023 19:30:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685475009; 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=SMGOVM8Ny4haYswisSUSB1OCQYXMGp4skE+tq+JD+gI=; b=c9TIp9ybw9ep7nf6wlxp+78PoUw1/hwAQ1cFW03CLwtm/ycXOE5O6D2D9oHwSAdQx/RM2O XzDCSIBESLdsIhwclbhZaTCCTaDwyM0Ao+k2YKtYNTcXTgToERXe/wYB5yI+mU8rTTnm3v ITSw86JmusJ8IfC/YXNvIS7nt45B21RJ4yY2AIcXYm7imqIby0N2QyJ+5x853HdHo+jks0 dpDOqgHR3grbRTc9Rd3EGCDXSO5Ny8kjv7wNIgX7/27tUtNxunY6uvsvYgMQab3wd3B2vj p030CuPi9ATSUe45bGmA2D/wUzSSKJE+lywQa2Tw/1xvsLqrX1wE95XdbYJrYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685475009; 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=SMGOVM8Ny4haYswisSUSB1OCQYXMGp4skE+tq+JD+gI=; b=cef7VsnPWE7GmGsUWFxdbJw41+U12QRcSSNMEc8CRuYeQksVVu0YhI59Xh5x025PpCVQvT d4Rw7x84eWUb36C5UbFKy80bfUofGltKOOyC/Aq13vha+4jePR4Stmsj/AB5RWfjUlu8iG 2kFSERp6j46JLckmYyPGFoIIyfWgiRXnIVzomaEAhIcwbxyJvAYsajkw9GBfunSlEFjLIA Tjr/EHsevHjnTZKOT2H0PBd6garNQhbgrD2PnCQY9FZQF08R0kFp41Swm/4kxWw2di/Adt QINcgSMX+lS05TrYeNeLFK8WvBjpOAty3SbaypPIwBt9vHlTqsGNAYXr6r3Dgw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685475009; a=rsa-sha256; cv=none; b=yW+pSZXW28oBtQ0oNQKiWFdWa3y8VxdPmsG4brn3N5VB1TeqISNpQLhd5OKNFqvP+zTm8K Iz04bqryUq0tx1LRaYu2W5DIgFQKXIuzfk4XTBOc62GCnSahnQtw0iXrnWYTxfp+E84t77 JUsKbbIThvR3akz3leg55ZD2k+RX0FQ1QufxI9oPk/OXOn0HvzVIJ3SntajjlNKD+oAwu+ r1w2myIFvKBg8Q2AVF77pgKlGdrQLnv9/xoDCnCHlx8LGnTMXOZgj7KE/Y+eqcDfDCYX9y uUwfsY0RtCurU83+Ps5s7Nj1te6mon/WxMOkMZZndwq4PXZ4FovpZ4pRP7pyVA== 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 4QW2Xw5pZ1z15Tc; Tue, 30 May 2023 19:30:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34UJU8gW048307; Tue, 30 May 2023 19:30:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34UJU8DO048305; Tue, 30 May 2023 19:30:08 GMT (envelope-from git) Date: Tue, 30 May 2023 19:30:08 GMT Message-Id: <202305301930.34UJU8DO048305@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: a306ed50ecd5 - main - inpcb: Restore missing validation of local addresses for jailed sockets 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a306ed50ecd57f060a549c14bc53a60b34aaa6bb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a306ed50ecd57f060a549c14bc53a60b34aaa6bb commit a306ed50ecd57f060a549c14bc53a60b34aaa6bb Author: Mark Johnston AuthorDate: 2023-05-30 19:15:48 +0000 Commit: Mark Johnston CommitDate: 2023-05-30 19:15:48 +0000 inpcb: Restore missing validation of local addresses for jailed sockets When looking up a listening socket, the SMR-protected lookup routine may return a jailed socket with no local address. This happens when using classic jails with more than one IP address; in a single-IP classic jail, a bound socket's local address is always rewritten to be that of the jail. After commit 7b92493ab1d4, the lookup path failed to check whether the jail corresponding to a matched wildcard socket actually owns the address, and would return the match regardless. Restore the omitted checks. Fixes: 7b92493ab1d4 ("inpcb: Avoid inp_cred dereferences in SMR-protected lookup") Reported by: peter Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D40268 --- sys/netinet/in_pcb.c | 6 ++++-- sys/netinet6/in6_pcb.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 350d08360105..5fddff89dd0a 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -2254,8 +2254,10 @@ in_pcblookup_hash_wild_smr(struct inpcbinfo *pcbinfo, struct in_addr faddr, continue; if (__predict_true(inp_smr_lock(inp, lockflags))) { - if (__predict_true(in_pcblookup_wild_match(inp, laddr, - lport) != INPLOOKUP_MATCH_NONE)) + match = in_pcblookup_wild_match(inp, laddr, lport); + if (match != INPLOOKUP_MATCH_NONE && + prison_check_ip4_locked(inp->inp_cred->cr_prison, + &laddr) == 0) return (inp); inp_unlock(inp, lockflags); } diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index da7ed5ca79e0..43f567461598 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1021,8 +1021,10 @@ in6_pcblookup_hash_wild_smr(struct inpcbinfo *pcbinfo, continue; if (__predict_true(inp_smr_lock(inp, lockflags))) { - if (__predict_true(in6_pcblookup_wild_match(inp, laddr, - lport) != INPLOOKUP_MATCH_NONE)) + match = in6_pcblookup_wild_match(inp, laddr, lport); + if (match != INPLOOKUP_MATCH_NONE && + prison_check_ip6_locked(inp->inp_cred->cr_prison, + laddr) == 0) return (inp); inp_unlock(inp, lockflags); }