From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AF62C4332F for ; Mon, 28 Nov 2022 18:06:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C45DA6B0072; Mon, 28 Nov 2022 13:06:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF5C46B0073; Mon, 28 Nov 2022 13:06:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A960F6B0074; Mon, 28 Nov 2022 13:06:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 96D266B0072 for ; Mon, 28 Nov 2022 13:06:10 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 67D04160E4F for ; Mon, 28 Nov 2022 18:06:10 +0000 (UTC) X-FDA: 80183630100.08.B7DC11D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id AB2A818000B for ; Mon, 28 Nov 2022 18:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669658767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ls7PhYALLia6Ca4uW+eal0IBzPITDzYb5wkwc+H7LdA=; b=BpK97U3REPjpdy8knpszrBWx/b2QlJdC2iccr3BZa64Wbf9Scg/pcl4NXJ9tx3yVmIIwbT uGhMpqsPOjZZ2ulbb5ig71A9VvlvTiqL2lwswKp02YbCh4X2niQOuijRSqfpESmLtiKSal Wz1S6OCnqRiSxr1OvQZe0nVMA2TNuXo= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-393-sWD4ffSKN1C8neFp6K5Qmw-1; Mon, 28 Nov 2022 13:06:05 -0500 X-MC-Unique: sWD4ffSKN1C8neFp6K5Qmw-1 Received: by mail-wr1-f69.google.com with SMTP id l8-20020adfc788000000b00241ef50e89eso2234294wrg.0 for ; Mon, 28 Nov 2022 10:06:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ls7PhYALLia6Ca4uW+eal0IBzPITDzYb5wkwc+H7LdA=; b=EHjiVj72C9I3N3weeQSH39jCnBx5mzHgZSA5+6xo4Q8qS+2ymCK5w8ICcgjaXhqn34 Uq6af/akdzlwOpKks3jjQYkNSYDN1Y1ppN6bsGXCo+/ieuWQyfiNhUb7OdCTBwvI+ATS pflN4QG//YJ5T49s3efit7X9ZqiVI52/EYHYc9eNi9aiyQDnystguHJENx+HZ04jfLn4 0GnNUKG6IegdbFQQkVwmJqhO2p2Jc8IbLD3R2i5C163BOpXRvhho4O93HFLJNsHutJYR 9yTYsq6agTY4JyAfoeB92dFgD4pbrbGrBU/OiGsErzXgpnhY43f7yJNModM1hJBSOsXx tUMg== X-Gm-Message-State: ANoB5pn68jFTdki9QMJgLIZf5xb9N7aa0Ix58Ip/JjeBqhndsxYVznuT irIj4taJvjxJhT7EGQNxhXvy2Dncu84HzisEgn+gLJ6A+kuv6JTshLpiDSmS/M47soSHHiqWAtL 3eaXEJGpBZAQ= X-Received: by 2002:a7b:c454:0:b0:3b4:be28:d800 with SMTP id l20-20020a7bc454000000b003b4be28d800mr25382395wmi.170.1669658763826; Mon, 28 Nov 2022 10:06:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7z2AUHPt9xIYsZQcqpTl0DnSuSUoPVM0oCfQkyzSF5aefGZsV+BwNQxXir3xLNlMrX6J5c6w== X-Received: by 2002:a7b:c454:0:b0:3b4:be28:d800 with SMTP id l20-20020a7bc454000000b003b4be28d800mr25382358wmi.170.1669658763546; Mon, 28 Nov 2022 10:06:03 -0800 (PST) Received: from ?IPV6:2003:cb:c702:9000:3d6:e434:f8b4:80cf? (p200300cbc702900003d6e434f8b480cf.dip0.t-ipconnect.de. [2003:cb:c702:9000:3d6:e434:f8b4:80cf]) by smtp.gmail.com with ESMTPSA id u1-20020a5d5141000000b002365cd93d05sm11295450wrt.102.2022.11.28.10.06.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 10:06:02 -0800 (PST) Message-ID: <54f43e4d-5124-b2c8-c6d4-ce0bf4547eaf@redhat.com> Date: Mon, 28 Nov 2022 19:06:01 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v3 3/3] mm/khugepaged: Invoke MMU notifiers in shmem/file collapse paths To: Jann Horn Cc: security@kernel.org, Andrew Morton , Yang Shi , Peter Xu , John Hubbard , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20221125213714.4115729-1-jannh@google.com> <20221125213714.4115729-3-jannh@google.com> <66cfc9ba-868c-9620-fbfc-38931c76ff50@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669658770; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ls7PhYALLia6Ca4uW+eal0IBzPITDzYb5wkwc+H7LdA=; b=QWlapBJ+/hcl8LSISe8vMDBCfBLwlPoq/FkS0yfEa/gPD/oDw3xL5eguFbR0CH/UMvzLSB PteB2T0KFC0J32fdu9VPGZKvcrS3qISd1DSZQFu1gY+eNyd8x/T5jH0VZmpnJ28vnmNUu7 h443BZNWeO2HD5CuBTERuUr4IVzFDFI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BpK97U3R; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669658770; a=rsa-sha256; cv=none; b=RmQJVhN68txSN0jknDCQwr2YBuAOwN5650j2xip1mh4Vpiy5Yjmwoc3eGR1wdYfnz9713D yKP3h39ODQZb3fxd0qg7JXksF7EuPExHBf1W1WWA4QwT/hyrR6Wpf21di4I4NDIlgOwzOL A7GFyRmAhVp6p/L+aBE4seKwPuA3VC0= X-Stat-Signature: 7j5thf3krh3jrac7ss71zkpibupxmy6b X-Rspamd-Queue-Id: AB2A818000B Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BpK97U3R; spf=pass (imf06.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1669658767-964394 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 28.11.22 18:57, Jann Horn wrote: > On Mon, Nov 28, 2022 at 6:37 PM David Hildenbrand wrote: >> >> On 25.11.22 22:37, Jann Horn wrote: >>> Any codepath that zaps page table entries must invoke MMU notifiers to >>> ensure that secondary MMUs (like KVM) don't keep accessing pages which >>> aren't mapped anymore. Secondary MMUs don't hold their own references to >>> pages that are mirrored over, so failing to notify them can lead to page >>> use-after-free. >>> >>> I'm marking this as addressing an issue introduced in commit f3f0e1d2150b >>> ("khugepaged: add support of collapse for tmpfs/shmem pages"), but most of >>> the security impact of this only came in commit 27e1f8273113 ("khugepaged: >>> enable collapse pmd for pte-mapped THP"), which actually omitted flushes >>> for the removal of present PTEs, not just for the removal of empty page >>> tables. >>> >>> Cc: stable@kernel.org >>> Fixes: f3f0e1d2150b ("khugepaged: add support of collapse for tmpfs/shmem pages") >> >> I'm curious, do you have a working reproducer for this? > > You're on the CC list of my bug report to security@kernel.org > with title "khugepaged races with rmap-based zap, races with GUP-fast, > and fails to call MMU notifiers". That has an attached reproducer > thp_ro_no_notify_kvm.c that is able to read PAGE_POISON out of freed > file THP pages through KVM. > Ah, the mail from early October, thanks (drowning in mail). You're amazingly skilled at writing reproducers. -- Thanks, David / dhildenb