Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp45531pxb; Tue, 12 Jan 2021 19:34:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJwc7CWQ3UKYV+2OUFl/TaD8Dz1fCOrxt1aIjPpbpV1CQzAR8z5z4o4wKzGLmok/rNzHM9ZT X-Received: by 2002:a17:906:ca47:: with SMTP id jx7mr69438ejb.237.1610508845624; Tue, 12 Jan 2021 19:34:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610508845; cv=none; d=google.com; s=arc-20160816; b=d/C78ru1uGm7GfiCLPf1LKjfM4jy1tZaOTIkgo9P3UWx4DWqK+egAYpo1Y7DPEpcn2 bde6GSm95qzHVPhPphIOmZO6uSa0j0+OkvLCVzq+ZRC74ZA8HQmyTGsIpe4QyA4teXE7 iunzaElxqFrZ9OTZKtm1tXVii2Nid2iAveJWf9xZEwQUpPReSbY7n2piUptI4Q092B/g AjG/LAUhF4j20qPVmYcs16rdStWQ0g2B59EIKQ6le+C0U94N+AoTuNYiBJ3884YXt8xG +llQkms+zUkssPaI6caf/2xG3a47rPE8SgGtF2guQXhPpp+wAfSoTjTyTtWWViMOE2Nq yGvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=ExLznwThawuTbJyTIm5Arp9VEpqF0RS06oUV/Yikwmk=; b=KcR/YkmU//byUAVexhqd6XsJkeokAbPG1x42BvJNFD0Ou+Lm8YRzQnWi3OozIVuqhS hayLYb5QFXWNU4QVwd4pN1rR0QaIAS/o+BvoyjRQUlvIjsohwFQPdwIw20y0bY8efL2P u+cAqiUvoD+BW4BxVpLVH8Nno1DU6z+L5+AvmE/tyUpzJ2FGBQrw+5oA+z74harjIHN5 sXPnktMauxiV8Q/wFCeUQiChJAqnSjty8QkAX8PEoDx9pFek7BtrAr8VZWR1MctuPhUj oOBMyG8DMiTT8K2LSr9IyCWZyfwR5l3fJJ0ctylqmGPsF4+zjKmZkpcvs16/HxOOTbNu Ki4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=H5KRgSNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si322511ejd.409.2021.01.12.19.33.42; Tue, 12 Jan 2021 19:34:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=H5KRgSNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437143AbhAMAnJ (ORCPT + 99 others); Tue, 12 Jan 2021 19:43:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392389AbhAMAcY (ORCPT ); Tue, 12 Jan 2021 19:32:24 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB68C061786 for ; Tue, 12 Jan 2021 16:31:44 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id t6so88238plq.1 for ; Tue, 12 Jan 2021 16:31:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=ExLznwThawuTbJyTIm5Arp9VEpqF0RS06oUV/Yikwmk=; b=H5KRgSNPwE1C8dCIrYHz4KtK0VDnitGlIiJ5wkmflzfdAWNYBWrjI+x0lE0zO2SNoA FXlp6wgVDUsVJQRm3vvVn3Shs9HVLKgdwJNlBF0dNbKnzo1+BuCvl34LTSL9ZzmiYsLl F3nQJXVhKj5lG+Mgv+zKysbXn4t4oRHQJFQRKgfVQlrxlI8XN575A4gBpNiAoD6I9NQP 5tewyt0Jmput92WVXpSlMwal47KHRr8phA5wL8rRRZ5VGLR0kaOlkMchU5uxhGxd70q5 6Pk6WBhRao7xFx9VDFX+btxBzDOb75c7fyf1OiD4On7J7qPFe6GGhrvWZeFHO4zWw9se IzNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=ExLznwThawuTbJyTIm5Arp9VEpqF0RS06oUV/Yikwmk=; b=A67qe2mW9jXZbAQQ5SMN025FnlorTqOiXn2EPNpTAVwNvOOGZnuvMthCvH75VDwXUq l2YS5RsezqKNwRXO5k2L8K1sUOfKF5Di8urjnRk1BpRq8n1nzEhV5IyGydgeN84qCmem JAvN2LyA8RYbepV7DiRqQVicUN/Gq+TkfPeso0K6zUnXUFatrhjynvL6E29qPaFVlnrM gUMumUF8Jkd5Qt0cNN2veukfp6asFh6pTV6SzmqDF29mPvxi92gcDI/lKJoyjODbV9YE Dsu5E4W2KObKjL7aO9fVdggAyXQZBrousw1yRYK4/iwMlEyB+TKRq7N7xADxivcCoarO CpMg== X-Gm-Message-State: AOAM530fHtjp+2cTdRnS+7Mc85xE6XNTuxW6HRgsRSstpclNlXB5JWy9 gni7Wqce/UcVjk+xFn4t2LyYDw== X-Received: by 2002:a17:90a:5405:: with SMTP id z5mr306369pjh.13.1610497903418; Tue, 12 Jan 2021 16:31:43 -0800 (PST) Received: from ?IPv6:2600:1010:b015:9bd0:bda1:66ef:aea3:7e99? ([2600:1010:b015:9bd0:bda1:66ef:aea3:7e99]) by smtp.gmail.com with ESMTPSA id 73sm152935pga.26.2021.01.12.16.31.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jan 2021 16:31:42 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] mm/userfaultfd: fix memory corruption due to writeprotect Date: Tue, 12 Jan 2021 16:31:41 -0800 Message-Id: <68095DFB-7D72-480E-BDF3-3C88B8428867@amacapital.net> References: Cc: Will Deacon , Yu Zhao , Laurent Dufour , Peter Zijlstra , Vinayak Menon , Linus Torvalds , Andy Lutomirski , Peter Xu , Andrea Arcangeli , linux-mm , lkml , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , stable , Minchan Kim , surenb@google.com In-Reply-To: To: Nadav Amit X-Mailer: iPhone Mail (18C66) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jan 12, 2021, at 2:29 PM, Nadav Amit wrote: >=20 > =EF=BB=BF >>=20 >> On Jan 12, 2021, at 1:43 PM, Will Deacon wrote: >>=20 >> On Tue, Jan 12, 2021 at 12:38:34PM -0800, Nadav Amit wrote: >>>> On Jan 12, 2021, at 11:56 AM, Yu Zhao wrote: >>>>> On Tue, Jan 12, 2021 at 11:15:43AM -0800, Nadav Amit wrote: >>>>>> I will send an RFC soon for per-table deferred TLB flushes tracking. >>>>>> The basic idea is to save a generation in the page-struct that tracks= >>>>>> when deferred PTE change took place, and track whenever a TLB flush >>>>>> completed. In addition, other users - such as mprotect - would use >>>>>> the tlb_gather interface. >>>>>>=20 >>>>>> Unfortunately, due to limited space in page-struct this would only >>>>>> be possible for 64-bit (and my implementation is only for x86-64). >>>>>=20 >>>>> I don't want to discourage you but I don't think this would end up >>>>> well. PPC doesn't necessarily follow one-page-struct-per-table rule, >>>>> and I've run into problems with this before while trying to do >>>>> something similar. >>>=20 >>> Discourage, discourage. Better now than later. >>>=20 >>> It will be relatively easy to extend the scheme to be per-VMA instead of= >>> per-table for architectures that prefer it this way. It does require >>> TLB-generation tracking though, which Andy only implemented for x86, so I= >>> will focus on x86-64 right now. >>=20 >> Can you remind me of what we're missing on arm64 in this area, please? I'= m >> happy to help get this up and running once you have something I can build= >> on. >=20 > Let me first finish making something that we can use as a basis for a > discussion. I do not waste your time before I have something ready. If you want a hand, let me know. I suspect you understand the x86 code as w= ell as I do at this point, though :)