From nobody Tue Jun 14 22:19:23 2022 X-Original-To: dev-commits-src-main@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 BA76E857934; Tue, 14 Jun 2022 22:19:23 +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 4LN2sl4XW2z4qpb; Tue, 14 Jun 2022 22:19:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655245163; 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=QngLTHpZFJ7ajylirYhBqg7MDYxIMsWKpOcklFeF5Ds=; b=aJoyk9N3B9LhB9b4fm+/f05mLJody7mqxmp/laAszGh5PZgPSieTWa+Ndhd2uutaoHyyK0 mMhCApmXdQE8ZolL0QrSdmb+aJECXZOsoGIhmHP7foE2MMDPSjk+OqTg4isas2roJlT3P3 lAF+ZaUEhSNrB7n1y4rZhY4y6sY00rZhcG3mSrK9eh+4fZbvJj6GsEhlaUfUWkDm23Mc0s 5qdnWGF7XhiOsoa1O9fBRb+9BGcPYCDM3ycAd3BuC3S+yD/zvv0xyxAJiTSGClvUnm0y3g vzJiD/xzSHIt/Ts/AGf259yveTkkk+MQb+1xEDbEn9FcuP0wQWNbFJGnvsfE3g== 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 7794B12BAA; Tue, 14 Jun 2022 22:19:23 +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 25EMJNiM084787; Tue, 14 Jun 2022 22:19:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25EMJNcE084786; Tue, 14 Jun 2022 22:19:23 GMT (envelope-from git) Date: Tue, 14 Jun 2022 22:19:23 GMT Message-Id: <202206142219.25EMJNcE084786@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: d0443e2b9832 - main - vm_fault: Fix a racy copy of page valid bits List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: d0443e2b9832f01319bcaaece8102d998bf81f01 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655245163; 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=QngLTHpZFJ7ajylirYhBqg7MDYxIMsWKpOcklFeF5Ds=; b=X9A/+AYyhkIfD6jLJCowbtJTvif1ZDKyzAVvq5IVZnjhjByoBGJh8AY/Lnu8WSU4x6J1eF tmARCmknHirt+xnJGW08kOA9ZMGAnVEtrkBLUyhTCas1hGe/oPQPjF3V1jsQx7ID7ZFi7i qe31/ZqF5hcZzJ+CSZSWbrmdXdRKDvrSKAjPte6juHBv7Qm/bGxsizewJ5dNUvhgNIDr98 /Ja2r63U139ABt4wsBlDAi3yF+TWRi+pgvxtaqt8sXzJ8JlUlrVMXxh+Y4w+agFpte4gjS mVoyE6HSv7i3cPxby3MVdWsE1TKvxJE/00aXXoYMCy2P4hrQz0JwqP6x3tXnxg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655245163; a=rsa-sha256; cv=none; b=W1bNgilO1Cd22nBQWPjJDFigziRKKP93PQXg8XgcKBBjJ1luL6wovI8MuOZHEdjCy9cKYH 5qqXTC6TR9fFEF1XEblONbJwontOVfbbRcZDu9jXzAeLmUTe3A1z55nkUBfTd4HYa5sDs4 yIWTmI9PZCbO3mPh+ZHVKZhyrl7mZ36s5W2IdYYkK8Tqa175MlGeJ0EUgP5MhSFnb7Ox/P sQKsLvyMPIsEplWRwDSAfy7hliwGPSPNH0xr8ogGHe1UGGYmqtWsuA/Py9baTF2c2qTR9K rcB69koYEBR5GhaiCUnMCeMqXwtOZee8WfSd2lkFUtGbGOAHo1OyI7m5SF98Gg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d0443e2b9832f01319bcaaece8102d998bf81f01 commit d0443e2b9832f01319bcaaece8102d998bf81f01 Author: Mark Johnston AuthorDate: 2022-06-14 20:36:54 +0000 Commit: Mark Johnston CommitDate: 2022-06-14 22:18:09 +0000 vm_fault: Fix a racy copy of page valid bits We do not hold the object lock or a page busy lock when copying src_m's validity state. Prior to commit 45d72c7d7fca we marked dst_m as fully valid. Use the source object's read lock to ensure that valid bits are not concurrently cleared. Reviewed by: alc, kib Fixes: 45d72c7d7fca ("vm_fault_copy_entry: accept invalid source pages.") MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35471 --- sys/vm/vm_fault.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index cfdd39de3ac2..3aca14777830 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -2099,8 +2099,15 @@ again: goto again; } pmap_copy_page(src_m, dst_m); - VM_OBJECT_RUNLOCK(object); + + /* + * The object lock does not guarantee that "src_m" will + * transition from invalid to valid, but it does ensure + * that "src_m" will not transition from valid to + * invalid. + */ dst_m->dirty = dst_m->valid = src_m->valid; + VM_OBJECT_RUNLOCK(object); } else { dst_m = src_m; if (vm_page_busy_acquire(dst_m, VM_ALLOC_WAITFAIL) == 0)