From owner-dev-commits-src-all@freebsd.org Tue Apr 6 19:20:11 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 088205B57F3; Tue, 6 Apr 2021 19:20:11 +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 4FFHRF1nF4z4dX1; Tue, 6 Apr 2021 19:20:08 +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 BDB6011C15; Tue, 6 Apr 2021 19:20:06 +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 136JK6Th000732; Tue, 6 Apr 2021 19:20:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 136JK63K000730; Tue, 6 Apr 2021 19:20:06 GMT (envelope-from git) Date: Tue, 6 Apr 2021 19:20:06 GMT Message-Id: <202104061920.136JK63K000730@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: 71a0b26df14a - stable/11 - vm_fault: Shoot down multiply mapped COW source page mappings 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/11 X-Git-Reftype: branch X-Git-Commit: 71a0b26df14a18b720faaa924bd4e18fcb9638d5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 19:20:11 -0000 The branch stable/11 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71a0b26df14a18b720faaa924bd4e18fcb9638d5 commit 71a0b26df14a18b720faaa924bd4e18fcb9638d5 Author: Mark Johnston AuthorDate: 2021-04-06 19:09:01 +0000 Commit: Mark Johnston CommitDate: 2021-04-06 19:09:01 +0000 vm_fault: Shoot down multiply mapped COW source page mappings Reviewed by: kib, rlibby Discussed with: alc Approved by: so Security: CVE-2021-29626 Security: FreeBSD-SA-21:08.vm --- sys/vm/vm_fault.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index cb21edb23f05..1d4736aa92bc 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1147,6 +1147,33 @@ readrest: vm_page_unwire(fs.m, PQ_INACTIVE); vm_page_unlock(fs.m); } + + /* + * Typically, the shadow object is either + * private to this address space + * (OBJ_ONEMAPPING) or its pages are read only. + * In the highly unusual case where the pages of + * a shadow object are read/write shared between + * this and other address spaces, we need to + * ensure that any pmap-level mappings to the + * original, copy-on-write page from the backing + * object are removed from those other address + * spaces. + * + * The flag check is racy, but this is + * tolerable: if OBJ_ONEMAPPING is cleared after + * the check, the busy state ensures that new + * mappings of fs.m can't be created. + * pmap_enter() will replace an existing mapping + * in the current address space. If + * OBJ_ONEMAPPING is set after the check, + * removing mappings will at worse trigger some + * unnecessary page faults. + */ + vm_page_assert_xbusied(fs.m); + if ((fs.first_object->flags & OBJ_ONEMAPPING) == 0) + pmap_remove_all(fs.m); + /* * We no longer need the old page or object. */