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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57169C19F29 for ; Wed, 27 Jul 2022 19:24:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C541C67B7; Wed, 27 Jul 2022 19:24:52 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 262EFC67B7 for ; Wed, 27 Jul 2022 19:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8PMF9RAfUsWsnizFrlCJPvao6aXNiFYw1zm8tW5odss=; b=UTld7/z9lGtIVo/RpBaSKOEH8v UrD4YlPiJURock7BXSSlf1jzkbcbdGDlsQo4AyRaJMgLpW6dGSkIBjqsPwBYDCX0Jg36XSWyUTnXY c3SpqEKj0514G8SqlIZ5BSczg8Rd2SFYdXgyIWdnLQ8lHIDSMFaIw/CKuiqoxIpWX8PIeq+RTSW/z qi0bUlwtjysoMUYLMPHCIxbq+JRykUdzQFC08EDFKdMoRYhgcDGBm4AqR715MlPZr84szRGq4nLIB OLolH7N0QQzZg9AcV4rJEM1saEU5fDy20jEBISvTwquU5zR45qN6WFTcerdrDiP/HE0W66HM3BYvz SyX38R9A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oGme6-003AhV-H5; Wed, 27 Jul 2022 19:24:38 +0000 Date: Wed, 27 Jul 2022 20:24:38 +0100 From: Matthew Wilcox To: Zack Rusin Subject: Re: [PATCH] mm: Fix a null ptr deref with CONFIG_DEBUG_VM enabled in wp_page_reuse Message-ID: References: <20220727191407.1768600-1-zack@kde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220727191407.1768600-1-zack@kde.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Miaohe Lin , Jan Kara , David Hildenbrand , NeilBrown , Yang Shi , dri-devel@lists.freedesktop.org, Michal Hocko , David Howells , linux-mm@kvack.org, Khalid Aziz , Don Dutile , Christoph Hellwig , mombasawalam@vmware.com, Andrea Arcangeli , Minchan Kim , Rik van Riel , Hugh Dickins , Liang Zhang , Mike Rapoport , Jason Gunthorpe , David Rientjes , Pedro Demarchi Gomes , Jann Horn , John Hubbard , Shakeel Butt , banackm@vmware.com, Muchun Song , Peter Xu , Suren Baghdasaryan , Vlastimil Babka , Hongchen Zhang , Oleg Nesterov , krastevm@vmware.com, Nadav Amit , Andrew Morton , Roman Gushchin , "Kirill A. Shutemov" , Mike Kravetz Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Jul 27, 2022 at 03:14:07PM -0400, Zack Rusin wrote: > From: Zack Rusin > > Write page faults on last references might not have a valid page anymore. > wp_page_reuse has always dealt with that scenario by making > sure the page isn't null (or the reference was shared) before doing > anything with it. Recently added checks in VM_BUG_ON (enabled by the > CONFIG_DEBUG_VM option) use PageAnon helpers which assume the passed > page is never null, before making sure there is a valid page to work > with. > > Move the VM_BUG_ON, which unconditionally uses the page, after the > code that checks that we have a valid one. Message-ID: