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=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 30A30C433E0 for ; Fri, 7 Aug 2020 16:48:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFA68221E2 for ; Fri, 7 Aug 2020 16:48:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="tosFGBkU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFA68221E2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4BB188D0005; Fri, 7 Aug 2020 12:48:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46CB48D0001; Fri, 7 Aug 2020 12:48:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3339E8D0005; Fri, 7 Aug 2020 12:48:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 1B8E68D0001 for ; Fri, 7 Aug 2020 12:48:09 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AFA52181AEF0B for ; Fri, 7 Aug 2020 16:48:08 +0000 (UTC) X-FDA: 77124355056.28.size30_591289d26fc1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 7E95D6C1D for ; Fri, 7 Aug 2020 16:48:08 +0000 (UTC) X-HE-Tag: size30_591289d26fc1 X-Filterd-Recvd-Size: 4914 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Fri, 7 Aug 2020 16:48:07 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id h19so2861470ljg.13 for ; Fri, 07 Aug 2020 09:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/WqT29bWdZ2/40qJaFhIMPQiWP1q4wAK2hW9rsZct4A=; b=tosFGBkUdBtkORQ302MrskHF6W1NJn73L8KF7SI5iRkle/CF4Dwt4NZFGVXebtmzXG HsBYvr72pzC/KUPThj8WJTCzrd+v6BVPLW1y8SzgtryTby72VWeXTx+CT2MKNB1YDfN9 SA7YvpKGGmzeYGUt88bvNeJ/pp5bOH3gVflhPad4MLNtkJKR1Td9doEOZVUabMRXTzJg ugwjYxmCQMe4lM9xs7oBi7q8EiY6yI6Xp1IuCsC24IcBm4Vj6PyDCgjft4fvTkggp7Gt DQh9RYUPgrd0T4fDvmOwMQE0Imr/njG3gTNPY9IfpntfDN93DxOJMob1OYnDnLcvcEoo x52g== 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=/WqT29bWdZ2/40qJaFhIMPQiWP1q4wAK2hW9rsZct4A=; b=IkYJa2pStmBKcnaGO5kQ/aaZjt9bEg2M6+Sbowi1As0LAoKyh1iDSXV7TqQ7b0eYo6 UIa7aYXTT/I8NABeCq0mas1ANp9h9l+hNst33pTqgo3NI+gSfZJJUN0ROvf80/CH5TOr O3W4du7i6ezup/0B+MOnaAGfklrAtp7kZCjzUQ4crRsa4D2+6Gm4xLj/ywfA5Uz4jz7w 6rn6hB0sLdv+nwM9TCWvjUTyaOBuZXjaA1QI9T8G9e1/r3FPE1KdfICqy4WnY0lHl5x9 fHMPrD1ErvN1EbsNond1IpwJdaQF9Vzanyj2Pi6bLHyHZe4QhTs1WxQcaN1MavxM2/vX aT+Q== X-Gm-Message-State: AOAM531R0SQ4+PXc19sQPZ2ig1bXs4HoaROzW/H+um5HmbshW4AIATIk ubJybXXSzCozPt98er17mAYjIw== X-Google-Smtp-Source: ABdhPJyWCK5+nfQ9lsBZI6fqTkGgAHf6OjC/UpCb+1nuGec3mjuNu7oJmNNVKY/wIJIFaaGQ7Mp9IA== X-Received: by 2002:a05:651c:110:: with SMTP id a16mr7191490ljb.152.1596818886276; Fri, 07 Aug 2020 09:48:06 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id v9sm4341665lja.81.2020.08.07.09.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 09:48:05 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 74CED102FA7; Fri, 7 Aug 2020 19:48:05 +0300 (+03) Date: Fri, 7 Aug 2020 19:48:05 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: John Hubbard , Andrew Morton , LKML , linux-mm@kvack.org, cai@lca.pw, rppt@linux.ibm.com, vbabka@suse.cz, william.kucharski@oracle.com, "Kirill A . Shutemov" Subject: Re: [PATCH v2] mm, dump_page: do not crash with bad compound_mapcount() Message-ID: <20200807164805.xm4ingj4crdiemol@box> References: <20200804214807.169256-1-jhubbard@nvidia.com> <20200807143504.4kudtd4xeoqaroqg@box> <20200807151029.GE17456@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200807151029.GE17456@casper.infradead.org> X-Rspamd-Queue-Id: 7E95D6C1D X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Fri, Aug 07, 2020 at 04:10:29PM +0100, Matthew Wilcox wrote: > On Fri, Aug 07, 2020 at 05:35:04PM +0300, Kirill A. Shutemov wrote: > > On Tue, Aug 04, 2020 at 02:48:07PM -0700, John Hubbard wrote: > > > If a compound page is being split while dump_page() is being run on that > > > page, we can end up calling compound_mapcount() on a page that is no > > > longer compound. This leads to a crash (already seen at least once in > > > the field), due to the VM_BUG_ON_PAGE() assertion inside > > > compound_mapcount(). > > [...] > > > +static inline int head_mapcount(struct page *head) > > > +{ > > > > Do we want VM_BUG_ON_PAGE(!PageHead(head), head) here? > > Well, no. That was the point of the bug report -- by the time we called > compound_mapcount, the page was no longer a head page. Right. VM_BUG_ON_PAGE(PageTail(head), head)? > > > A similar problem is possible, via compound_pincount() instead of > > > compound_mapcount(). > > > > > > In order to avoid this kind of crash, make dump_page() slightly more > > > robust, by providing a pair of simpler routines that don't contain > > > assertions: head_mapcount() and head_pincount(). > > > > I find naming misleading. head_mapcount() and head_pincount() sounds like > > a mapcount/pincount of the head page, but it's not. It's mapcount and > > pincount of the compound page. > > OK, point taken. I might go for head_compound_mapcount()? Or as I > originally suggested, just opencoding it like we do in __page_mapcount(). I'm fine either way. -- Kirill A. Shutemov