From nobody Tue Dec 14 17:39:35 2021 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 7BC9B18F24E2; Tue, 14 Dec 2021 17:39:35 +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 4JD5Gv1nKPz4Rt6; Tue, 14 Dec 2021 17:39:35 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1D16447C9; Tue, 14 Dec 2021 17:39:35 +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 1BEHdZhM061688; Tue, 14 Dec 2021 17:39:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BEHdZFC061687; Tue, 14 Dec 2021 17:39:35 GMT (envelope-from git) Date: Tue, 14 Dec 2021 17:39:35 GMT Message-Id: <202112141739.1BEHdZFC061687@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 185e659c40ef - main - inpcb: use locked variant of prison_check_ip*() 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: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 185e659c40ef4dbd6855dfa0f735f06dfcf01c6f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639503575; 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=KKlaNhew/5wvqtMz2lwZABH1rKvdU7zcKz3UxDcNl+Y=; b=TuRLINdZ11tBvi5KLPcb0kDVa9M0HfvTeE7DAw1Vm71uYlmdIqqgjK6d9/8ssTtzevB+Wk zc6lffpvrcHewdWAH4vzwdJT5ysv2HLDwlF7pA1RHGxWtz5Zl11ybwUpDojEi9e6+2QWOM Z8D3/Xw0rljODK3py1dOg0qkF0kZ0ZjAM116TBAFJmI8SVXNpOWNKVrLTu4y/Ku1gO+mYE wkxEsFSFIUMe0NlVOgTgW/d2TNaJ8gst8MWbp32uMb/cit4jTxCYco9osfoJ1Mt4VOhUsP olpYOEzzs1uTYDE1gfWWuHTX51Y1/paGn7JjyAh4Vy1ar5MECKVxRhiJQAT9lQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639503575; a=rsa-sha256; cv=none; b=Hq9HhGBz9yOtHT+Ns9vs2Zmq4BwB9u4NyjVS+0A41yLcMT5bHTyIS9fMw43349QMUdOFGf J9ivtGq3vb5yLYm/lj330zX/mFjgSIWiy3zSYlV4H9cltiUCJ01FPSNdj5RIn+jzJFmqCY zliOBbjegX4ZHGlsfwXW49Nt83zYWW1+CowC21i1AV1d9Fwe9YAeR5uTVmafC1Ltd3Lk52 R4wWEQBQR4qwaNZBVtzC5EIORxvhMGGxGURttjQbSJ94qWYCEYhoYMOVeu3FqqxU6Rrp/C C9QndK8oHyB4XbBXDmB8oCZHPxDBb5by3F2Z3SwsVUhZxYbOYO002DQZqjoRtg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=185e659c40ef4dbd6855dfa0f735f06dfcf01c6f commit 185e659c40ef4dbd6855dfa0f735f06dfcf01c6f Author: Gleb Smirnoff AuthorDate: 2021-12-14 17:38:52 +0000 Commit: Gleb Smirnoff CommitDate: 2021-12-14 17:38:52 +0000 inpcb: use locked variant of prison_check_ip*() The pcb lookup always happens in the network epoch and in SMR section. We can't block on a mutex due to the latter. Right now this patch opens up a race. But soon that will be addressed by D33339. Reviewed by: markj, jamie Differential revision: https://reviews.freebsd.org/D33340 Fixes: de2d47842e8 --- sys/netinet/in_pcb.c | 4 ++-- sys/netinet6/in6_pcb.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index ffcc93553c22..4dc3c737b914 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -2330,8 +2330,8 @@ in_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in_addr faddr, injail = prison_flag(inp->inp_cred, PR_IP4); if (injail) { - if (prison_check_ip4(inp->inp_cred, - &laddr) != 0) + if (prison_check_ip4_locked( + inp->inp_cred->cr_prison, &laddr) != 0) continue; } else { if (local_exact != NULL) diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index d6c6593f2adf..f86c72958a9e 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1079,8 +1079,8 @@ in6_pcblookup_hash_locked(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, injail = prison_flag(inp->inp_cred, PR_IP6); if (injail) { - if (prison_check_ip6(inp->inp_cred, - laddr) != 0) + if (prison_check_ip6_locked( + inp->inp_cred->cr_prison, laddr) != 0) continue; } else { if (local_exact != NULL)