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 0CB71C433E2 for ; Mon, 31 Aug 2020 06:07:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A7BE320707 for ; Mon, 31 Aug 2020 06:07:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cmF2xLSO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7BE320707 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0A8C76B0002; Mon, 31 Aug 2020 02:07:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0576C6B0003; Mon, 31 Aug 2020 02:07:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E89426B0005; Mon, 31 Aug 2020 02:07:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id D48276B0002 for ; Mon, 31 Aug 2020 02:07:06 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 83598181AEF1D for ; Mon, 31 Aug 2020 06:07:06 +0000 (UTC) X-FDA: 77209830852.12.cub59_4d0ef362708d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 53C8918009139 for ; Mon, 31 Aug 2020 06:07:06 +0000 (UTC) X-HE-Tag: cub59_4d0ef362708d X-Filterd-Recvd-Size: 5053 Received: from mail-oi1-f193.google.com (mail-oi1-f193.google.com [209.85.167.193]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 31 Aug 2020 06:07:05 +0000 (UTC) Received: by mail-oi1-f193.google.com with SMTP id k4so82358oik.2 for ; Sun, 30 Aug 2020 23:07:05 -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=ztuJ7lCE7kvEopSezi/ervbTmQwS2BBYgYbiSUHWDXw=; b=cmF2xLSOc0U8iPN/z0M/2KlwqgwRrp6zq9MwpiRV27UnbWuS7mGffAS2K5qX6wGZDA vKV3JN+iiDvuhHUrUpKdss5ebLyYtzRN8/X6y16byabkAS2Nyq0e/ZjqlVt+h7dHjzAS 2+/a8PNuK2ZUVeGks4uD5ObjruiD14v/ThBq/Mb2pru7WMFg0ZkunMkPWRsdWw+d9xwh RLNt+mr1jdeBPF6KYi/e1cYn/Gbn+24t9EoWZgX7LTiPH8ccaSYYeTkNq0kAVW5A7TSN pz91sXm5kCQ8WCklfAXzQHteSKQsJjFIR3w7sUTaXaVWPcqay+RgSPuaiDr1sa+X689+ uXCg== 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=ztuJ7lCE7kvEopSezi/ervbTmQwS2BBYgYbiSUHWDXw=; b=rCt4sq/2Gk6x67ps9Kqk2xC3rA05bVviFoTW/CXGsDkGQKtingobxyvzHuuhzGsh8O GL4cYrJezcvSNyXBk4LURU1l2Qg6ChT1ECT06cT14U9TZr5m97tdvBlj9n0Li10iokpf W4xAJpb0rRTkGAoH+Dgm4AduciDx5htABGOHH7xaOKQeWmDhitgdVHzY5NDoolJoY0YE SuM9kpXjx1E+SalpoUIwG1la0eK42XWCWzmIndn9L8vRV9oJLpC3Cd/CGEhbJVu+Yhk1 7CyhJI3dKRSZfPI9bItlDaohTI771FNfk4Pb/fyRW2oItxS5oVW7MG66XKNv6I4RP5z4 R0yg== X-Gm-Message-State: AOAM531ok7zMuc7EYjfMUT8VT965GyPAOI5ypFzBEY3x6vDBdx23GJ3W p8VShF5pCOhBB4TIVzWnKLDOyg== X-Google-Smtp-Source: ABdhPJz/zU/QKQdg3JGY2l0l+MAtlTVJhSk3I1VuspUkRP/wEWRSujcUG5/U0enSatTYPzam6ne/kQ== X-Received: by 2002:aca:cd93:: with SMTP id d141mr14485oig.33.1598854024866; Sun, 30 Aug 2020 23:07:04 -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 126sm597160oof.28.2020.08.30.23.07.02 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Sun, 30 Aug 2020 23:07:03 -0700 (PDT) Date: Sun, 30 Aug 2020 23:06:47 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Jann Horn cc: Andrew Morton , Linus Torvalds , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, 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: <20200827114932.3572699-8-jannh@google.com> 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 X-Rspamd-Queue-Id: 53C8918009139 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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, so still vulnerable to that extra issue. It won't be as satisfying as removing all traces of mmget_still_valid(), but right now I think you should add an mm->core_state check there instead. (I do have a better solution in use, but it's a much larger patch, that will take a lot more effort to get in: checks in pte_offset_map_lock(), perhaps returning NULL when pmd is transitioning, requiring retry.) Or maybe it's me who has missed what you're doing instead. Hugh