Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1306414pxk; Mon, 31 Aug 2020 15:55:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd/Ltog5PbFEKGLUuFie7/9pBFFnr/VQClB5ChkpHPNFCmOdd6vCTQhc2/g8F28Oau9v1V X-Received: by 2002:a05:6402:515:: with SMTP id m21mr3225504edv.348.1598914528846; Mon, 31 Aug 2020 15:55:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598914528; cv=none; d=google.com; s=arc-20160816; b=VcE9gOPZORYtn5rU+B3g4FlWcMWKYmMtJUQ8EnfJWxDLGVtjzVZQPyn4zRg8a0CiQn JWXaXHo7IvQQK7l6CDDpN3VbS93cmcYzAntqnqjVOi78JFCQnJQYsnV85xWC5RGmPgIc buwM9JBwre6p/5MIl8vVRKmAyPJPnJlC1daWhr8JV+2/HV/TW7wTTmrffQw4HB5rZUKE IqKqFiIY4oET9qc08ZdCK78EthcoGAUNHqXNog/0sxZGBcKH+agpfsMW/tOgQpT8O5VQ n1yY3nMZjF4c+YOevk/MV5xYJH2uWIaQ8AoeGEDb6T5mCfSj1DMiq/IfeuxI/Ek+tFJb FcHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=ALZ0cI088e7LavEE1zCuQl43dEIuq04xSG5XkBRnPb4=; b=UnMQxj7r8Hw4/G8bQlr+NIb1LYnXOTZUGoGq53n8VS/rF8B5OXh7QunS7dUVSsjjQ6 KCIEicxfNI0r8vsZ/0pbszd8M7Qithtijt6tCelSicUB0d9tE7wcYUtueBkbCl33/UhN PQ6tEDJA31CTMCmCuKuUBoUr9vHWPVnw9b9SBdosA3zKsOjxA24DGUVI8Np0lyJPqOKM A9syLB2aIJ9CLVco/gVpCM/JbGkikW105hCq7TszQDQp77svULEotYhs4bA6r5qUk2+y Wk84qvUdoyyEV//qkx8haxE412fuUGlURvtZoVeD+AUEqtzenL+PU3fJGelEo/7aVUJ5 anyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cXMgYuoM; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v4si1866046edi.28.2020.08.31.15.55.06; Mon, 31 Aug 2020 15:55:28 -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=@google.com header.s=20161025 header.b=cXMgYuoM; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728472AbgHaUgf (ORCPT + 99 others); Mon, 31 Aug 2020 16:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726472AbgHaUge (ORCPT ); Mon, 31 Aug 2020 16:36:34 -0400 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E36C061575 for ; Mon, 31 Aug 2020 13:36:33 -0700 (PDT) Received: by mail-oo1-xc42.google.com with SMTP id k13so1466666oor.2 for ; Mon, 31 Aug 2020 13:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=ALZ0cI088e7LavEE1zCuQl43dEIuq04xSG5XkBRnPb4=; b=cXMgYuoMdUne52TPYEQ+RFvNI7fYFdPFXmQNr2cTfKwhpwzXvn0C1UEkM2V288lmdo Bm09UkGWR+j1NnjJtpdsgh4pu7bbkdCOYa4W6LaTudcHbvcA1MeAlIMLvCJZGeFuwJSd SvC9QFsb45+heQ0E4L08PQpV0mZ/S1U6t2LLcDOgdATl+i0OpteWp66eF+2mglWO+iNz Un2AVZq41XE8zU42eC/gUHnwuKWSRdtpSqKVwu6OTepuiEVN/pA74/aDMO4b5HYmNr/s tVHEKv2wvuGJw9bi7Jl8VE6G61KmRs9aF6dPYuIbzLMXOzjKoUJmYltdWsB2lQYUceaK J7Xw== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=ALZ0cI088e7LavEE1zCuQl43dEIuq04xSG5XkBRnPb4=; b=pp8OgM/fApvLzymo+iALJL4IirKbrIF9oDOw+S/LbP5H+BnMPF5Xjb/+3UC+dAorLx prBZLFS9jLEg8Yi4LbxpkQRGGeQh/0/i79+kvl+w9AZLtGh81ypjJLulC6wwyvi6sQZc X0Au1BdvhFbK5SEo1ehQO6ZV6rvotjlZ4AVpqcvnEUFOEndqHGc3K6nnetpe98+cRpqf ItnqVK97+t2n4cK48ceMpDEf8pSXK7EX3xyl4jrOiQSdiTILYL5BhfQ/OEUJ5dk4rt0h XptZ0auww7ATW9Ez1nQ8cgplGR/r6Hcap6QgGfhhyBRxl943fvVgHBcNLsbqb7y1CIh/ ImdA== X-Gm-Message-State: AOAM530b76URWMUrG0Ss3iyycR+1beJN1Y6WfF3yKNpyUmdRJSjzrf78 v1uOsCfs7eCTdd96ZvaO9E+45g== X-Received: by 2002:a4a:d157:: with SMTP id o23mr1078948oor.2.1598906192708; Mon, 31 Aug 2020 13:36:32 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id l22sm2035015oot.22.2020.08.31.13.36.30 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Mon, 31 Aug 2020 13:36:31 -0700 (PDT) Date: Mon, 31 Aug 2020 13:36:16 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Jann Horn cc: Hugh Dickins , Andrew Morton , Linus Torvalds , Christoph Hellwig , kernel list , Linux-MM , linux-fsdevel , Alexander Viro , "Eric W . Biederman" , Oleg Nesterov Subject: Re: [PATCH v5 7/7] mm: Remove the now-unnecessary mmget_still_valid() hack In-Reply-To: Message-ID: References: <20200827114932.3572699-1-jannh@google.com> <20200827114932.3572699-8-jannh@google.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 31 Aug 2020, Jann Horn wrote: > On Mon, Aug 31, 2020 at 8:07 AM Hugh Dickins wrote: > > On Thu, 27 Aug 2020, Jann Horn wrote: > > > > > The preceding patches have ensured that core dumping properly takes the > > > mmap_lock. Thanks to that, we can now remove mmget_still_valid() and all > > > its users. > > > > Hi Jann, while the only tears to be shed over losing mmget_still_valid() > > will be tears of joy, I think you need to explain why you believe it's > > safe to remove the instance in mm/khugepaged.c: which you'll have found > > I moved just recently, to cover an extra case (sorry for not Cc'ing you). > > > > > --- a/mm/khugepaged.c > > > +++ b/mm/khugepaged.c > > > @@ -431,7 +431,7 @@ static void insert_to_mm_slots_hash(struct mm_struct *mm, > > > > > > static inline int khugepaged_test_exit(struct mm_struct *mm) > > > { > > > - return atomic_read(&mm->mm_users) == 0 || !mmget_still_valid(mm); > > > + return atomic_read(&mm->mm_users) == 0; > > > } > > > > > > static bool hugepage_vma_check(struct vm_area_struct *vma, > > > > The movement (which you have correctly followed) was in > > bbe98f9cadff ("khugepaged: khugepaged_test_exit() check mmget_still_valid()") > > but the "pmd .. physical page 0" issue is explained better in its parent > > 18e77600f7a1 ("khugepaged: retract_page_tables() remember to test exit") > > > > I think your core dumping is still reading the page tables without > > holding mmap_lock > > Where? get_dump_page() takes mmap_lock now: > Right, sorry for the noise, that's precisely what 6/7 is all about, and properly declares itself there in its Subject - I plead that I got distracted by the vma snapshot part of the series, and paid too little attention before bleating. Looks good to me - thanks. > > I don't think there should be any paths into __get_user_pages() left > that don't hold the mmap_lock. Actually, we should probably try > sticking mmap_assert_locked() in there now as a follow-up? Maybe: I haven't given it thought, to be honest. Hugh