From nobody Wed Feb 01 23:41:38 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 4P6djb4xyXz3cMX6; Wed, 1 Feb 2023 23:41:39 +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 4P6djb1Qxpz3NVR; Wed, 1 Feb 2023 23:41:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675294899; 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=SyP4R68ctwuKvDKW11N2M8BKcyN9Xl3+4BAawgsFTbI=; b=Nn4GanKGknWQNP3qSEtzbtsFne/nHBApfN07eURC08+S9IDLBrgjMqUp1eIEWI4GmIyRQy 8r/V2Khq2QEhM8ptlelCOQQ3JvjfRuPeQePiw8NXB1XtRL9RJHQXhPbhuauSU7ZL7PJabG AA4MjiT5Ylqm8Wi7UJ2QDaH64N0Nh6fX2Kt91tYMkV6qvqTIMUnw0jA5a9kFWd2FMIY5dg DaP2n9XTy0qjO8q3Iu1gB7M4fnPb6L4aP0E6SCt5/8fzRByDCIqqT9Qvu9QCQr9UvF7xDf 5F2osqV36lsnSFn76PDreK+xM95L4ZNQr0ik37HqbbD8iu1Dbj7U3L7Q7TxFYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675294899; 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=SyP4R68ctwuKvDKW11N2M8BKcyN9Xl3+4BAawgsFTbI=; b=DoazvZ2/EfhZAjfaW9aWddW6sc9Aqt4SrOujrbUOyEsWUsdP2pG6SGfyKEiJIYQn+gTPty pHxmIiepy5VoNKzKxWq1r3Aud9zTEomFXjjIs9aFmJhE0fxtawHCpwx8Qn4Me8jbvsemPA /tXKXgnt2Wt2FWXZ9Dkq1zoRfz7ue4588KO35LirJIfYDvt2lCp5lk9Vgy0sBeC/B8dfaS GD3beLGF3Ve8akyaDctSvlI9R7LaHYjUUT/bBftSqwhC+2L3ePqmFCcTkKZvpTwkn1i3uw qRJaKNlXTPeJAT3EUz1jr20nenvs3M53MnH1ve7PP9df0OHHvM1iHC9A53gGdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675294899; a=rsa-sha256; cv=none; b=Pqxk1X+QIVd07lBWGphvk4+ofCGAb8S7wONuKpA+rfd0Lc/zArfB3ga5HjWJB+QYxg4c06 9z7qbPSotdmXBx/X3092mJ333rRdixIgFYv88+26P3rfnsq33LYiDJ6RsdyDPVDbaIKvHY ukp4QkBSFqVBe4hT8DNu8/GipXGpY4ACM1oDksoG9tutYQ3YTtO1BrZNLM3+9nhCMIyCZ2 BFt1zuhKt7g0WEJIkJpcfTRhynKehAi5OpBnQpWcbt8Wi4hcTGfGb9j0KSViuwgcxNmvAR A4nQcsexcoSSQucK/jfJ2ORaSSWfKtLY2FcW7SQh0FMAke4crwZIIOtQbU44dA== 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 4P6djb0XgrzYWY; Wed, 1 Feb 2023 23:41:39 +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 311NfcsE089004; Wed, 1 Feb 2023 23:41:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 311NfcIQ089003; Wed, 1 Feb 2023 23:41:38 GMT (envelope-from git) Date: Wed, 1 Feb 2023 23:41:38 GMT Message-Id: <202302012341.311NfcIQ089003@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 25c862ae503a - main - libthr pshared: correct a bug in allocation 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 25c862ae503a1c99458f4e055fd50c878fadbea3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=25c862ae503a1c99458f4e055fd50c878fadbea3 commit 25c862ae503a1c99458f4e055fd50c878fadbea3 Author: Konstantin Belousov AuthorDate: 2023-02-01 20:12:45 +0000 Commit: Konstantin Belousov CommitDate: 2023-02-01 22:59:27 +0000 libthr pshared: correct a bug in allocation When __thr_pshared_offpage() is called for allocation, it must not use the cached offpage for the key. Instead, the cached offpage must be unmapped and removed from the cache, if any. It is legitimate for the user code to unmap the shared lock object without destroying it, and then mapping something over the freed VA to carry another shared lock. In this case the cached offpage must be un-cached. PR: 269277 Reported by: rau8344@gmail.com Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38345 --- lib/libthr/thread/thr_pshared.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/libthr/thread/thr_pshared.c b/lib/libthr/thread/thr_pshared.c index 37b44ab73582..446e9983bcae 100644 --- a/lib/libthr/thread/thr_pshared.c +++ b/lib/libthr/thread/thr_pshared.c @@ -232,11 +232,16 @@ __thr_pshared_offpage(void *key, int doalloc) int fd, ins_done; curthread = _get_curthread(); - pshared_rlock(curthread); - res = pshared_lookup(key); - pshared_unlock(curthread); - if (res != NULL) - return (res); + if (doalloc) { + pshared_destroy(curthread, key); + res = NULL; + } else { + pshared_rlock(curthread); + res = pshared_lookup(key); + pshared_unlock(curthread); + if (res != NULL) + return (res); + } fd = _umtx_op(NULL, UMTX_OP_SHM, doalloc ? UMTX_SHM_CREAT : UMTX_SHM_LOOKUP, key, NULL); if (fd == -1)