Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1422660pxk; Thu, 10 Sep 2020 15:12:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5WimbF8m/pfySfvIYh8F7ESLtu6cO+8Rb7jxsV5DY9ymlhH4dfMZHxozKHgfnjbqqFiNO X-Received: by 2002:a17:906:af6a:: with SMTP id os10mr10928640ejb.34.1599775937211; Thu, 10 Sep 2020 15:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599775937; cv=none; d=google.com; s=arc-20160816; b=AAbnIGz8Zcm0JoVp5eLifEzdnOGltB96Boe8HPVgcwL41NFvIZ7JEiKNQ5LEAErm2i ikmonp6svpW9g1m1p0Jn0G8oc3ZtYvfhr7bxOfu6xWUhnCYuNRD3veh4n0mohdWzGF3i +mhc2JLs13o/H0k92oGWKiXgWKCkX0SmT1Oq+WPUeodnoR/DAN0bVDvEpspW8WZOdJP0 XMvLxwai6/RsAjIXJQIP7zh9O9ApHOj7YACdQ7Ws+vT8A6P8GTHQG5/bQa3c7F8etSEo XMoKYunVZrZy1My9rifI4jEz9jAZAkuIHGmyoA72uhIR7IS6bp8sgvC4NJMv6Tx/U5nH 4FxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=GR2McBa3c+WLdwdMHBorMHUc/q8N5804j6NsqXnydDM=; b=F0QmGJf2VRRf5/t6qBmcj7ITpn4ZHphrHUXFTw+X605EE3aHz/VuHdWwAt+H9OnAjF tEuyySjTifnCLSXfJfm/nWqBCLVSWTgUP+ty3nOUyIGilBzCCiyCOSMNDhcxB37YSZLh h545moRGCQF22TjZru6F9TrhOUsJ12rVTCwLnVDD9+4aUUghAxEAYXoGzkkAfmng4ubr uHV3xq+4l/iUBzmWYTOGaTy27vFfdzHhkMadoBYuGKJCaJGmD+NJLiJcjbFDuv5I+uLe oCOb7YtpktjooNlmNhoGnsZR1e1RbJQ9PpPy0MCPINU3DsCyMyrwAeCo0a30fe1fFKAB 9sLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=AUJ38pNh; 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 u5si4789591edy.385.2020.09.10.15.11.54; Thu, 10 Sep 2020 15:12:17 -0700 (PDT) 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=@ziepe.ca header.s=google header.b=AUJ38pNh; 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 S1725355AbgIJWLZ (ORCPT + 99 others); Thu, 10 Sep 2020 18:11:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725287AbgIJWLT (ORCPT ); Thu, 10 Sep 2020 18:11:19 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD8FC061573 for ; Thu, 10 Sep 2020 15:11:18 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id n10so6197702qtv.3 for ; Thu, 10 Sep 2020 15:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GR2McBa3c+WLdwdMHBorMHUc/q8N5804j6NsqXnydDM=; b=AUJ38pNh0a4cQmfCkYoSwn3bQPVBlwFjRFCC3eqLV97NVXGHYiBtqhCLijvLN5pJxI M83viNf12njX2Xn6pt8DTRLrTv+Yi2XRlLLobXY4F/+TXjKcrclhFAukpdgOBtvUoKKm ZdTIQ7EeYqDWWsH+dJqOVGuwap0dXDj7iwPesU2Oz2BoLbKastojnW9wmbmn+mbjkErc UAHzLwSE0IYeouh1DRajO8KaCPaHMnEMzhWcO3K0AkwuFJxqf+b2xT1vzMKusCE1sXGr XG2/iiyv7+8B0IDMPiPTapf/TRd17VN1WEByhVr0AC1whRwkUI37PQCd3/YwB5bWZ3LP KYbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GR2McBa3c+WLdwdMHBorMHUc/q8N5804j6NsqXnydDM=; b=KwvKk9L51/3kMEuY/hdfBmUo+vLcfAf5vQKfdfT15wVwmHHFCNjpxMEId1C6pjVpbG IzjadDhHYHqacFA6jhkh0C0qZv11GTP+pJl2eVN4fS974mK01o9wWfDo6T587ihcKWwG ck2IkMDBpBth9aVI14CMQ1W8LdyqIQsVaNhE3oNW6V0iEwrPtZmupmlpOrDP/EQq4Q3u 4m8M5zkf1nFs5HXB7rDxiyFa2MaAz5HFyrbfu3MGOBpljSq6LNSlDSpiJBmpZfRdXFLk TRBIFjB2EaUhnSV1ecCQT2s27I/dYofecDXcwwoB/llOY+hkbdIShuFiYCo8RBPgc/iH OqwA== X-Gm-Message-State: AOAM531oIxa1S716zXnN3TGjcsSye5BWXz/VvabQe4JjY3M6pHHm2T2d 0OIGqE0gHhnbM+HYugIvIyfRnw== X-Received: by 2002:ac8:66da:: with SMTP id m26mr10507099qtp.111.1599775878060; Thu, 10 Sep 2020 15:11:18 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id w36sm100489qtc.48.2020.09.10.15.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 15:11:17 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kGUmi-004RcY-HM; Thu, 10 Sep 2020 19:11:16 -0300 Date: Thu, 10 Sep 2020 19:11:16 -0300 From: Jason Gunthorpe To: John Hubbard Cc: Linus Torvalds , Alexander Gordeev , Gerald Schaefer , Dave Hansen , LKML , linux-mm , linux-arch , Andrew Morton , Russell King , Mike Rapoport , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jeff Dike , Richard Weinberger , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Arnd Bergmann , Andrey Ryabinin , linux-x86 , linux-arm , linux-power , linux-sparc , linux-um , linux-s390 , Vasily Gorbik , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda Subject: Re: [RFC PATCH v2 1/3] mm/gup: fix gup_fast with dynamic page table folding Message-ID: <20200910221116.GQ87483@ziepe.ca> References: <20200907180058.64880-2-gerald.schaefer@linux.ibm.com> <0dbc6ec8-45ea-0853-4856-2bc1e661a5a5@intel.com> <20200909142904.00b72921@thinkpad> <20200909192534.442f8984@thinkpad> <20200909180324.GI87483@ziepe.ca> <20200910093925.GB29166@oc3871087118.ibm.com> <20200910181319.GO87483@ziepe.ca> <0c9bcb54-914b-e582-dd6d-3861267b6c94@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0c9bcb54-914b-e582-dd6d-3861267b6c94@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 10, 2020 at 02:22:37PM -0700, John Hubbard wrote: > Or am I way off here, and it really is possible (aside from the current > s390 situation) to observe something that "is no longer a page table"? Yes, that is the issue. Remember there is no locking for GUP fast. While a page table cannot be freed there is nothing preventing the page table entry from being concurrently modified. Without the stack variable it looks like this: pud_t pud = READ_ONCE(*pudp); if (!pud_present(pud)) return pmd_offset(pudp, address); And pmd_offset() expands to return (pmd_t *)pud_page_vaddr(*pud) + pmd_index(address); Between the READ_ONCE(*pudp) and (*pud) inside pmd_offset() the value of *pud can change, eg to !pud_present. Then pud_page_vaddr(*pud) will crash. It is not use after free, it is using data that has not been validated. Jason