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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2192C433EF for ; Fri, 8 Apr 2022 01:22:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E0726B0071; Thu, 7 Apr 2022 21:22:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 190746B0073; Thu, 7 Apr 2022 21:22:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07F6D6B0074; Thu, 7 Apr 2022 21:22:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id ECCB46B0071 for ; Thu, 7 Apr 2022 21:22:17 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6990A18446BB2 for ; Fri, 8 Apr 2022 01:22:17 +0000 (UTC) X-FDA: 79331961114.27.A41BC15 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf30.hostedemail.com (Postfix) with ESMTP id EC79380004 for ; Fri, 8 Apr 2022 01:22:15 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id ku13-20020a17090b218d00b001ca8fcd3adeso10557666pjb.2 for ; Thu, 07 Apr 2022 18:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=A6OclNo6fSItQpTxQTpaUCER7lHP82G03LIl77so8jw=; b=zSb4agSs6+sEx1Gos/tvaPy9cnZsjfM6UBsveMu1xbXuLiS2sYW5lZu5i5fVIaC2Uc TnBbYZzHnB6Lfdx4TY/UdQbAZQm0p/8+FUrOEYttBaMsqVgEBTaUxbv+MIbOmKf1hN88 1y4BpCaILLtwuVHG+12DtsYjcMbWUaz489ALsW7l/a5CmmDrI9GkoUMUsMAHHsHqgUIR cUhDqIqhiUxL0nDHDJZH1iJxSzUbp8LKnCIWFtXLBPm4+qRPAFgIPzoYgLs9WNl8bhb/ DmpmuQnOVqtw5NH7a1ZqG/NN+gIQwyGPCj3MT0Tfd3rP2jBe0g2HTC+b4Y0LjmweN30a Agvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=A6OclNo6fSItQpTxQTpaUCER7lHP82G03LIl77so8jw=; b=cVD5p25LAZf5WM6OOZmvZagM+alTBPSpzshiBRAhAe6rUNakgX1ABNm3+LB2R/oNUp FwCPz0yDhxDIEN+oOtpVWWCXIi7bDsGH6Y6HDiZK9ea0ctL4dAvu5H2Grz6j/OffcXSn xeoL/jzJ1g6XlvHQK5GNZO69T2YasykJ0Pe5a619uWTntPML4NC9n6EXx/BTsP+LpQgK qu+Di1iEIsIbQnqt+uLjitc4L1jQAKLBsBFPuGHFaIY/bxryYogADKS++LYx5UQWdl+x WlF45xxeVFjt6bvgRsW3bJMXEkOZVTbFt/ZOXWEDrM6ukrczFMUKCXh+KwRC9MLMfO1c UOmA== X-Gm-Message-State: AOAM5336+lKjBIoxQdn/+1k/tRa9YSc3pZa2430r3zv+ecnFoDHdq7HS 2Lb3iCwmXFiIMZ3sshuY+Lsbig== X-Google-Smtp-Source: ABdhPJwhsbSFMkUvU8wzdDL8blnk++f7WzgqCYdkmeqpKagtwMsEnmQtneoW8sDRmpOVWWTI40PeuA== X-Received: by 2002:a17:90a:bf12:b0:1ca:69bd:9a10 with SMTP id c18-20020a17090abf1200b001ca69bd9a10mr18877946pjs.92.1649380934743; Thu, 07 Apr 2022 18:22:14 -0700 (PDT) Received: from [10.76.15.169] ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id q28-20020a656a9c000000b00372f7ecfcecsm21038355pgu.37.2022.04.07.18.20.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Apr 2022 18:21:10 -0700 (PDT) Message-ID: Date: Fri, 8 Apr 2022 09:17:10 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: Re: [PATCH] mm: fix kernel NULL pointer dereference in page_vma_mapped_walk Content-Language: en-US To: Matthew Wilcox Cc: Mike Kravetz , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220407064008.71869-1-pizhenwei@bytedance.com> From: zhenwei pi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: myk8yi8coga3i55ryx3apy5jee19zb9a Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=zSb4agSs; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf30.hostedemail.com: domain of pizhenwei@bytedance.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=pizhenwei@bytedance.com X-Rspamd-Queue-Id: EC79380004 X-HE-Tag: 1649380935-94284 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 4/7/22 22:17, Matthew Wilcox wrote: > On Thu, Apr 07, 2022 at 02:54:42PM +0100, Matthew Wilcox wrote: >> On Thu, Apr 07, 2022 at 02:40:08PM +0800, zhenwei pi wrote: >>> size_to_hstate(4K) returns NULL pointer, this leads kernel BUG in >>> function page_vma_mapped_walk. >> >> Yes, I think this is the right fix. It's not immediately obvious from >> the bug and the patch, but what's going on is: >> >> page_mapped_in_vma() sets nr_pages to 1. This is correct because we >> usually only want to know about the precise page, and not about the >> folio containing it. But hugetlbfs is special (... in so many ways ...) >> and actually wants to work on the entire folio. We could set nr_pages >> specially for hugetlb pages, but it's better to ignore it in >> page_vma_mapped_walk() for the hugetlb case. >> >> I'll fix up the changelog and add it to my pile of fixes that I'm >> sending tomorrow. >> https://git.infradead.org/users/willy/pagecache.git/shortlog/refs/heads/for-next > > I looked over the patch in context, and realised we now don't need to > call size_to_hstate since we're getting the hstate from the VMA. > > https://git.infradead.org/users/willy/pagecache.git/commitdiff/98ea02597b9967c0817d29fee2f96d21b9e59ca5 > Thanks! -- zhenwei pi