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 X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD9AFC433E6 for ; Mon, 31 Aug 2020 20:36:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 777E32078B for ; Mon, 31 Aug 2020 20:36:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cXMgYuoM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728402AbgHaUgf (ORCPT ); Mon, 31 Aug 2020 16:36:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726249AbgHaUgd (ORCPT ); Mon, 31 Aug 2020 16:36:33 -0400 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2FB1C061573 for ; Mon, 31 Aug 2020 13:36:33 -0700 (PDT) Received: by mail-oo1-xc41.google.com with SMTP id k63so1803083oob.1 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=fMkgZwZ1l3ht9Seh8kOLVOv/6Ad379i85fs8ov12c+uQ0/MWZIcq7wALLlQrUjIY8A wHZP04DB3Oofmg6mDPgNBoIXgEvfvv+ttnmAC1ehGDW+hXqxC0XLXH8hRwPgMuz2X6VM c+vjggoIHg4oMbZEwvMv3wa+17aIDa//cznodb2LH1pvCm0AR1TH415M7WVW4yDeFhiK HcLvwwDsk5o/9NwVY8JGx20JdjekWq+RW1IUssbyiEHsMbPZzfA0Nqtq4df8Ogy13PXA VR8B3OBbbEoF4Zs3Hi6OUBZGWnZSbMpNeE1TulkxTnFiBp8SzfsbYBpHgh1n8rAtjr9Y XPaQ== X-Gm-Message-State: AOAM532ejGAngkG+DI37VqWSi3IzCWgnvEorzWa1+wMaqzBAnx1kw7qq HAEQOEZnAR4w5tH70LCLcZB49g== X-Google-Smtp-Source: ABdhPJxlYmDe1he0nb+ZttHTJoAT3S1OZGqNC/UYyfdM76yoUFWtJWVAxMeAPXce/Tx266vERYW5SA== 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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