Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp757237pxk; Sun, 30 Aug 2020 23:08:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLUK0yuQ/DjMEzHA/IBVszAJERcRvqxj4lqrBtbGATEIB52R5jBGY+iMN9IYnOaMGspPjw X-Received: by 2002:a17:906:aed1:: with SMTP id me17mr10673652ejb.267.1598854106068; Sun, 30 Aug 2020 23:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598854106; cv=none; d=google.com; s=arc-20160816; b=yf2JsUq6w+RCfdtxiDeu6IzR3iyShLcMYPGJSwAHWmbZUqIXZ2aEv1KyB1zeHIsa5J Dr7UNsGmSmF2U3FcM9XbycJfQZtSSFMyovy5Ja9TjWynuVhPSkKLeI3xREb9os0R9EUr U1URCDYBsj594WtG/S/6L37iIPsk0ikKo0eKE5r8YVVROMhvnWQuYr6CF7QHBjjRTyaT BoZtswehOv2srnsm/+yhRcBEnuXrlsPvEgzT1MjesFEy758MSu3aJc+RGERtbW2v4eJv T+Ye+fsRsXDaSrJszCqrxon6waWjtp0vjL6WYenTgckfmd+zl8MB3h+9z29HplHatEzv aEmg== 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=ztuJ7lCE7kvEopSezi/ervbTmQwS2BBYgYbiSUHWDXw=; b=oSmGlD093SXQ+KNiJWE4Vi4rhGgJO5ya+vGIkwQWywYCdd4YhlgDEBxZbdfux+Mqaa 9xGuRfshXAcITUq9ACC7+ObAN4KiKgB5scR6HjcdQwgqnFvcsjguB3v3KCuVlDlUx4Ue d6r5k64NKx+RypMX7lNxKCj7Oseduc3o4qYJU32EGTaPsUCTjDXKgb+ZDyEAbehZuT9k oAzftcGHcf34eDqd9BvcFZmYgyq89V7lpjie8QkMTGSZKjlA6QmW6LGqiHlHh5gwyekU zYkUqN6fO8L80PgYzZAF0pKV6iLt9abYo6PS+Hn9INivMQOKtodt5mznQQ+/U5wkoofD il8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cmF2xLSO; 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 z2si5186670ejj.455.2020.08.30.23.08.03; Sun, 30 Aug 2020 23:08:26 -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=cmF2xLSO; 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 S1726427AbgHaGHJ (ORCPT + 99 others); Mon, 31 Aug 2020 02:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbgHaGHG (ORCPT ); Mon, 31 Aug 2020 02:07:06 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04405C061573 for ; Sun, 30 Aug 2020 23:07:05 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id y6so74853oie.5 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=LTBeZP7eGaoHiTFT0Uc2a21AT8O67ATI4A+mCVDoiOSYg+1KEFlkYkFHMpGDQvz0MA i0IRZMTFflF6P7+ugre1D0sdjBY+vG3k5CCx3U1VmpJJWRtcqhtwYRkFU+y0HVgVPc7m 2jouR95vbGUC4qxYeX1YKPhZyTa7S2oVANH2oytLkF4T3++NbB/kypCHWhpIdQEjS8RB 63rTv8L+t9DV7T6JBmnzZaJw1o1h5FwCga/ZD1tDWnuhFl8eFjlQuKjuAWERjRzPTpxP 2pwzU93Rz8phdfJEi/E4XNzievGHqKPI5Exo6/di86PnOBA+Z432UmsSqnfyE/O0yapx 0d8A== X-Gm-Message-State: AOAM533vo0guMvKv4mqruty8waMrCxBkoIdY/DKTl0EC4pkQYHIKBZds qhg2Mpr0XGFUlTYq6LuFKJc/lw== 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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