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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 6A37ECA90AF for ; Wed, 13 May 2020 11:21:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4546E23128 for ; Wed, 13 May 2020 11:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589368886; bh=6oDIQR6e2BZFHFyoEtJrflz30L2Mrq6KkKzNx0mGDm8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=imQ1CBpTtd48lW0hZZ3PYr/A1ki44zmz4QvsrlV7yzrrrT0MjFrvNPMpjG7KefRqQ xDqIXULRMb0sTd5mmyPTxqNMrRI2YfgEvm6GUA/SlifilJ4sCE0k+9s3vnTgGfkGXd yf3zCcIwmRl4Mo5R3o6TXpJ28CN7kpZV5B/FsmaE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732852AbgEMLVX (ORCPT ); Wed, 13 May 2020 07:21:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:52338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732496AbgEMLVX (ORCPT ); Wed, 13 May 2020 07:21:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 54F032078C; Wed, 13 May 2020 11:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589368882; bh=6oDIQR6e2BZFHFyoEtJrflz30L2Mrq6KkKzNx0mGDm8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q4SyeVeRtImiJCdSZa7Qmepd+cWrdTv2JJnco2C1RtM2MJP5EuBpDlmxOOkF8vsxg gdefx3xyABZeoAmOuOVXjQ7h7QP5UTq4um/1ty9DdDn246VCD3h6FbUcE/gPVzAJVo ZTPDn3Vru+XdMCpAcZoDWmf961miyNKPhe1Y5nIg= Date: Wed, 13 May 2020 13:21:20 +0200 From: Greg Kroah-Hartman To: Will Deacon Cc: Naresh Kamboju , sashal@kernel.org, Mark Rutland , catalin.marinas@arm.com, kyrylo.tkachov@arm.com, linux- stable Subject: Re: FAILED: patch "[PATCH] arm64: hugetlb: avoid potential NULL dereference" failed to apply to 4.9-stable tree Message-ID: <20200513112120.GB874540@kroah.com> References: <158928280292134@kroah.com> <20200513103545.GA20278@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200513103545.GA20278@willie-the-truck> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, May 13, 2020 at 11:35:45AM +0100, Will Deacon wrote: > [+Sasha, as I think he did the backport] > > On Wed, May 13, 2020 at 04:02:09PM +0530, Naresh Kamboju wrote: > > On Tue, 12 May 2020 at 16:56, wrote: > > > > > > > > > The patch below does not apply to the 4.9-stable tree. > > > If someone wants it applied there, or to any other stable or longterm > > > tree, then please email the backport, including the original git commit > > > id to . > > > > > > thanks, > > > > > > greg k-h > > > > > > ------------------ original commit in Linus's tree ------------------ > > > > > > From 027d0c7101f50cf03aeea9eebf484afd4920c8d3 Mon Sep 17 00:00:00 2001 > > > From: Mark Rutland > > > Date: Tue, 5 May 2020 13:59:30 +0100 > > > Subject: [PATCH] arm64: hugetlb: avoid potential NULL dereference > > > MIME-Version: 1.0 > > > Content-Type: text/plain; charset=UTF-8 > > > Content-Transfer-Encoding: 8bit > > > > > > The static analyzer in GCC 10 spotted that in huge_pte_alloc() we may > > > pass a NULL pmdp into pte_alloc_map() when pmd_alloc() returns NULL: > > > > > > | CC arch/arm64/mm/pageattr.o > > > | CC arch/arm64/mm/hugetlbpage.o > > > | from arch/arm64/mm/hugetlbpage.c:10: > > > | arch/arm64/mm/hugetlbpage.c: In function ‘huge_pte_alloc’: > > > | ./arch/arm64/include/asm/pgtable-types.h:28:24: warning: dereference of NULL ‘pmdp’ [CWE-690] [-Wanalyzer-null-dereference] > > > | ./arch/arm64/include/asm/pgtable.h:436:26: note: in expansion of macro ‘pmd_val’ > > > | arch/arm64/mm/hugetlbpage.c:242:10: note: in expansion of macro ‘pte_alloc_map’ > > > | |arch/arm64/mm/hugetlbpage.c:232:10: > > > | |./arch/arm64/include/asm/pgtable-types.h:28:24: > > > | ./arch/arm64/include/asm/pgtable.h:436:26: note: in expansion of macro ‘pmd_val’ > > > | arch/arm64/mm/hugetlbpage.c:242:10: note: in expansion of macro ‘pte_alloc_map’ > > > > > > This can only occur when the kernel cannot allocate a page, and so is > > > unlikely to happen in practice before other systems start failing. > > > > > > We can avoid this by bailing out if pmd_alloc() fails, as we do earlier > > > in the function if pud_alloc() fails. > > > > > > Fixes: 66b3923a1a0f ("arm64: hugetlb: add support for PTE contiguous bit") > > > Signed-off-by: Mark Rutland > > > Reported-by: Kyrill Tkachov > > > Cc: # 4.5.x- > > > Cc: Will Deacon > > > Signed-off-by: Catalin Marinas > > > > > > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > > > index bbeb6a5a6ba6..0be3355e3499 100644 > > > --- a/arch/arm64/mm/hugetlbpage.c > > > +++ b/arch/arm64/mm/hugetlbpage.c > > > @@ -230,6 +230,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, > > > ptep = (pte_t *)pudp; > > > } else if (sz == (CONT_PTE_SIZE)) { > > > pmdp = pmd_alloc(mm, pudp, addr); > > > + if (!pmdp) > > > + return NULL; > > > > > > WARN_ON(addr & (sz - 1)); > > > /* > > > > > > > on stable-rc 4.9 branch arm64 architecture build failed. > > > > CC arch/arm64/mm/hugetlbpage.o > > arch/arm64/mm/hugetlbpage.c: In function 'huge_pte_alloc': > > arch/arm64/mm/hugetlbpage.c:106:8: error: 'pmdp' undeclared (first use > > in this function); did you mean 'pmd'? > > if (!pmdp) > > ^~~~ > > pmd > > arch/arm64/mm/hugetlbpage.c:106:8: note: each undeclared identifier is > > reported only once for each function it appears in > > scripts/Makefile.build:304: recipe for target > > 'arch/arm64/mm/hugetlbpage.o' failed > > > > ref: > > https://ci.linaro.org/view/lkft/job/openembedded-lkft-linux-stable-rc-4.9/DISTRO=lkft,MACHINE=hikey,label=docker-lkft/893/consoleText Now dropped from 4.9 as well.