Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2205506rdb; Mon, 9 Oct 2023 17:08:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGUT7zFY3yWXswSs1HO95Ri3jMIvPkf9YkNvPPMKxWwYmTZsHV7BHS+/whGn2pUfqi1G6HC X-Received: by 2002:a17:902:ce8b:b0:1bc:7441:d81a with SMTP id f11-20020a170902ce8b00b001bc7441d81amr17387813plg.6.1696896481735; Mon, 09 Oct 2023 17:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696896481; cv=none; d=google.com; s=arc-20160816; b=QNl6zfPMoDEZRdmSHSIUxqupp21pmPfSJHa1Yvi0mU13iZXgXQpl75Cu49zWu+WC4N N6zlIT82ghzYC1LPenuUU4Tiz1uEyoueLkb6I4f1YqlYPAxK7xSSXQq6HCwXCTorY/T5 IdHFHtkQZKqcI2hfw33FfCqVlCQkPxW9h2VdZNRajh6uHNXvEafdgiYOhnmQo5VTin3T p4eKdTAgWdNigd503C7FfS9f1A7McnQRk5azhEChWpcqtAiv4tze5u5eeGnroaxSMA1w ts0cj2AunIp03a3hHgFTsaYOKI7zbZPauKNOYsqWI2C7I42dH5WRKGbZEaIobyUjNIom uSjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=rPPfWPehB9IwVqXA8LY2YeucqC4gfZUuB9/Cfwhhy0k=; fh=EtqyACDLRSE8BF6jPqAgeq617jB0F8Sw98iea2R/Ixo=; b=iace7yicztGypxDMgTe1lySJxWt59cSyo6vKeIZ2X1wP6inDqYP1+JRqVQCQ7ioNxr STxnkM4mDAoVVm+rznrnn89efXFlFV9EKzq//qvQFjuXhT+OL8JjkiG6nKNm8AhVTWSD YB42qbuHPkG2JrjuFZxvCNgVK3gTk5fkYa5gxI1YdtSO2fV2KAAdn8EzMHgG+njtoRgl X4yoUUaut9FFqr6vTmHzv+Adr7UbgrBrFupQAizcDm1NHdr3sFGOh0iXpW+M5gQ/DizI FQyMvnIVh5x7s8cQi/eRGPquziZO6CIm7Ck8VNC51qi+6WveecyH1sJ4cOzR9cq3B5xR kr7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=M8QqAFFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id n6-20020a170902e54600b001c72b13a1cbsi11375412plf.352.2023.10.09.17.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 17:08:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=M8QqAFFM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2281D823CA15; Mon, 9 Oct 2023 17:07:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379115AbjJJAHk (ORCPT + 99 others); Mon, 9 Oct 2023 20:07:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377918AbjJJAHj (ORCPT ); Mon, 9 Oct 2023 20:07:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03792A6 for ; Mon, 9 Oct 2023 17:07:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD330C433C8; Tue, 10 Oct 2023 00:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1696896457; bh=6b49PW5LaeMyJQFy8snvZ2ofXdD/Lial7GWWzU0yfhE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=M8QqAFFMRc3t/UxGKQLvGIV8tdRYA5+JgGdk/vKa7VjQBYOHnaoikyMPusYG+VD3Z oBng8VDURbRPyEpjCJTzj0oTbHLrABaY9NtQ4VgcZ6ddscwqcUpylA80UiHLK7h3Cx +A0fUcfOrN128LZK3iFGviEV2zPB0g+vZracjMyc= Date: Mon, 9 Oct 2023 17:07:10 -0700 From: Andrew Morton To: Mike Kravetz Cc: Konrad Dybcio , Anshuman Khandual , Xiongchun Duan , Barry Song <21cnbao@gmail.com>, David Rientjes , Miaohe Lin , Matthew Wilcox , linux-mm@kvack.org, Naoya Horiguchi , Joao Martins , David Hildenbrand , Michal Hocko , Oscar Salvador , linux-kernel@vger.kernel.org, Usama Arif Subject: Re: [PATCH v6 2/8] hugetlb: restructure pool allocations Message-Id: <20231009170710.b52f5a6e57c23d5caecce8ab@linux-foundation.org> In-Reply-To: <20231009151513.GB3846@monkey> References: <20230925234837.86786-3-mike.kravetz@oracle.com> <20230929205731.GA10357@monkey> <20231006030836.GC86415@monkey> <5d14b681-a2c9-4210-a0c1-bf38708b7998@linaro.org> <20231006223512.GC3861@monkey> <20231009032926.GA3376@monkey> <070bd916-d4d6-41c2-9f51-af35e80c96b9@linaro.org> <20231009150401.GA3846@monkey> <20231009151513.GB3846@monkey> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 17:07:59 -0700 (PDT) On Mon, 9 Oct 2023 08:15:13 -0700 Mike Kravetz wrote: > > This should also be empty and a noop. > > > > Is it possible that the misaligned kernel image could make these lists > > appear as non-empty? > > Actually, just saw this: > > https://lore.kernel.org/linux-mm/20231009145605.2150897-1-usama.arif@bytedance.com/ > > Will take a look, although as mentioned above prep_and_add_bootmem_folios on > an empty list should be a noop. Konrad, are you able to test Usama's patch? Thanks. From: Usama Arif Subject: mm: hugetlb: only prep and add allocated folios for non-gigantic pages Date: Mon, 9 Oct 2023 15:56:05 +0100 Calling prep_and_add_allocated_folios when allocating gigantic pages at boot time causes the kernel to crash as folio_list is empty and iterating it causes a NULL pointer dereference. Call this only for non-gigantic pages when folio_list has entries. Link: https://lkml.kernel.org/r/20231009145605.2150897-1-usama.arif@bytedance.com Fixes: bfb41d6b2fe148 ("hugetlb: restructure pool allocations") Signed-off-by: Usama Arif Cc: Fam Zheng Cc: Mike Kravetz Cc: Muchun Song Cc: Punit Agrawal Cc: Anshuman Khandual Cc: Barry Song <21cnbao@gmail.com> Cc: David Hildenbrand Cc: David Rientjes Cc: James Houghton Cc: Joao Martins Cc: Konrad Dybcio Cc: Matthew Wilcox (Oracle) Cc: Miaohe Lin Cc: Michal Hocko Cc: Naoya Horiguchi Cc: Oscar Salvador Cc: Xiongchun Duan Signed-off-by: Andrew Morton --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/hugetlb.c~hugetlb-restructure-pool-allocations-fix +++ a/mm/hugetlb.c @@ -3307,7 +3307,8 @@ static void __init hugetlb_hstate_alloc_ } /* list will be empty if hstate_is_gigantic */ - prep_and_add_allocated_folios(h, &folio_list); + if (!hstate_is_gigantic(h)) + prep_and_add_allocated_folios(h, &folio_list); if (i < h->max_huge_pages) { char buf[32]; _