Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp15392560rwb; Mon, 28 Nov 2022 11:02:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Q2obqPZPepChpLpPRpVJMhF4eIa7NqtXdQkEYJ5tSEtgfFJnIy3ATBTVs39p0ehLCclug X-Received: by 2002:a17:906:124d:b0:7ad:b822:d2e4 with SMTP id u13-20020a170906124d00b007adb822d2e4mr44705367eja.35.1669662143336; Mon, 28 Nov 2022 11:02:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669662143; cv=none; d=google.com; s=arc-20160816; b=Aqh/2oSX/Wo44xn8SFyG/KL9Ug7mVyEXg257GpegeUe1IugIpOb/zpwmSoC4GCOVpX x9ZA99Bwly6oOXoSPxsm6ez3TsozdxNAXJIAXtUR0cMz4uB58UdIod0xO0yY7aTzG7Lk lfa0uwPZW6JMART4ajdZuWU+4mq2SLuhcfEBRXCedEQH5L+M/idxxPSWeT1XZYh6Emb9 38ZDrv/+EfypZIjAQxUYecHnpbsxzXZ46v3LFPKRYhjPVGLdw/PWThed3EBGSl18ze5g eTJ0iZanpfVw2OdZW/Kqd3PqTIHEHvLZvFSR6IjN4KEYeFQQdGw06EcN70lIdxtCHG0v 6QQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=jT1tAFSnCzDikHJ9CZbuhgF0BEJlLq1HTdxSmwB6uss=; b=oEL47PWtoyADnP7S4KT6TnXYEGKTS3OLwEpliRPIMrl1wqcYIAKOc0Zv0VV49fwXFZ EZO5EHcDXGlGpjIA/wyclzvEtwyDJXlR2E+8xP9ZN5JrKhgAKvnjdSn5cFZSNoPoYqI4 /bRfx0o4K823+YdXei0ELJpMmCm2QLYWJ9Az8AbZTnuvs6t1mEv3nwQCuq0ySWzEhh1Y FSfOkAVRbBLK2NL2Il8vLHdHYZQ4KGZHjFEWin3npR7O00+SYUO7fhW1a3t68lXIu2Qs uJ96PUF/fOn2uq2qrl75qiJs69wnOyfbl9ayyq60p+I65lR+ogoMoDDu7goZ5certh1/ Jg9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DjCOTsXS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e18-20020a056402191200b0046ad8dfcfbasi8934890edz.344.2022.11.28.11.02.01; Mon, 28 Nov 2022 11:02:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DjCOTsXS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233167AbiK1RjS (ORCPT + 84 others); Mon, 28 Nov 2022 12:39:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233140AbiK1Rim (ORCPT ); Mon, 28 Nov 2022 12:38:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80A3863EB for ; Mon, 28 Nov 2022 09:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669657072; 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=jT1tAFSnCzDikHJ9CZbuhgF0BEJlLq1HTdxSmwB6uss=; b=DjCOTsXSHVVUhI0TBsmnF+5xXd7L1OoG7Jnh0uMlTJURCsBP1c7Rc8J99E/1TNFvLFNKft 3SQ/DxlHk2I6YhVkhRLXLFxO5b3T1tmSTRK/zj+B5tJkWg/QTSxAkwy731uJseA1rtyfkh TCV2AnGjsSoKOVBQE0TOcIvwZV0+aCo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-650-BuPJS_PZOXKkC8SDdWGvrw-1; Mon, 28 Nov 2022 12:37:50 -0500 X-MC-Unique: BuPJS_PZOXKkC8SDdWGvrw-1 Received: by mail-wr1-f71.google.com with SMTP id l8-20020adfc788000000b00241ef50e89eso2204302wrg.0 for ; Mon, 28 Nov 2022 09:37:50 -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=jT1tAFSnCzDikHJ9CZbuhgF0BEJlLq1HTdxSmwB6uss=; b=ZVxeG0zsqnU0Oy3868IJ0LtbHVrhrK3620SnMrzQC3ez7vYYGIpG3VdN6abfSUHhpi yBavD2oXEUfj/bHDdvHkcefFlQ7NQj3ipW2unmrKi6fg1yJjTK9QQc9mJah3h2+xrTRK 2kNnIhubrHNO6P9dCNvUIGoZZDwgUfiK6ghjIpZ0mb3BALK/UkfTbCYR95jcNTHtkjA3 7Rr+/iLCkgyOKSr75u6npFuyklkfrYTDRSb3oFZ33QfkOxtq287S5xwfylP1YQAgO6f1 xOLkeSkf6O3kO3oEt34d6P9Y9WDuXle6CH+2SnkpA7G608sC2XFf+4yWX0TK952bRu9s qC0Q== X-Gm-Message-State: ANoB5pnikjQJL2rIb/psJag5/6728tobiAQX7kuo6tzAVV+GN8/P/MGG bzzvIRYZdmnUQCPtqJzfNRdT+zco1Swdbv5fEPeNCOhv4ONV5v2rWKhZdM+0BEhkuNkW8pdZuxN zK7UACd9kOXl4WNvmLYBCrkRB X-Received: by 2002:adf:dfc6:0:b0:236:cfcf:8e36 with SMTP id q6-20020adfdfc6000000b00236cfcf8e36mr13266267wrn.323.1669657069635; Mon, 28 Nov 2022 09:37:49 -0800 (PST) X-Received: by 2002:adf:dfc6:0:b0:236:cfcf:8e36 with SMTP id q6-20020adfdfc6000000b00236cfcf8e36mr13266246wrn.323.1669657069343; Mon, 28 Nov 2022 09:37:49 -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 j15-20020a5d452f000000b002416e383e1csm11584060wra.25.2022.11.28.09.37.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 09:37:48 -0800 (PST) Message-ID: <66cfc9ba-868c-9620-fbfc-38931c76ff50@redhat.com> Date: Mon, 28 Nov 2022 18:37:47 +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 Content-Language: en-US To: Jann Horn , security@kernel.org, Andrew Morton Cc: 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> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20221125213714.4115729-3-jannh@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Change looks sane on quick glimpse. -- Thanks, David / dhildenb