From patchwork Fri Nov 5 20:39:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12605567 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98F9BC433FE for ; Fri, 5 Nov 2021 20:40:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 651AF611C4 for ; Fri, 5 Nov 2021 20:40:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 651AF611C4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 03D44940062; Fri, 5 Nov 2021 16:40:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2F09940049; Fri, 5 Nov 2021 16:40:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1EFF940062; Fri, 5 Nov 2021 16:40:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id CECED940049 for ; Fri, 5 Nov 2021 16:40:02 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8F8828249980 for ; Fri, 5 Nov 2021 20:40:02 +0000 (UTC) X-FDA: 78776043486.17.C4C2C3B Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf30.hostedemail.com (Postfix) with ESMTP id AFB2AE001982 for ; Fri, 5 Nov 2021 20:39:43 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 0F3006056B; Fri, 5 Nov 2021 20:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1636144800; bh=AggLZ8nA2+U/SPGcwOBQOGanO0LrnntBQMKbQkeoafk=; h=Date:From:To:Subject:In-Reply-To:From; b=zC/z0uwtkF3++ZxXOtOvmBkx6jaFjq1+pVoSrzGOYiDCNiljU/Y/neiIFsJ5noXSI SXg928D8ppbgsYBsxWcm/RnNh+zlE+BDeHxP1NVpK9uWBPvJ7h2egzwmzIs/CmGxpx +Giw21Z/f1hQyWfJZ0dxEDGpumchlCEYOHV1eZzQ= Date: Fri, 05 Nov 2021 13:39:59 -0700 From: Andrew Morton To: akpm@linux-foundation.org, edumazet@google.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, npiggin@gmail.com, torvalds@linux-foundation.org Subject: [patch 102/262] mm/large system hash: avoid possible NULL deref in alloc_large_system_hash Message-ID: <20211105203959.pBhGbu8m4%akpm@linux-foundation.org> In-Reply-To: <20211105133408.cccbb98b71a77d5e8430aba1@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AFB2AE001982 X-Stat-Signature: 1tcswpezwaz8ha78k4dzj11qb47zw56j Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="zC/z0uwt"; spf=pass (imf30.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1636144783-235260 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: From: Eric Dumazet Subject: mm/large system hash: avoid possible NULL deref in alloc_large_system_hash If __vmalloc() returned NULL, is_vm_area_hugepages(NULL) will fault if CONFIG_HAVE_ARCH_HUGE_VMALLOC=y Link: https://lkml.kernel.org/r/20210915212530.2321545-1-eric.dumazet@gmail.com Fixes: 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings") Signed-off-by: Eric Dumazet Reviewed-by: Andrew Morton Cc: Nicholas Piggin Signed-off-by: Andrew Morton --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/page_alloc.c~mm-large-system-hash-avoid-possible-null-deref-in-alloc_large_system_hash +++ a/mm/page_alloc.c @@ -8762,7 +8762,8 @@ void *__init alloc_large_system_hash(con } else if (get_order(size) >= MAX_ORDER || hashdist) { table = __vmalloc(size, gfp_flags); virt = true; - huge = is_vm_area_hugepages(table); + if (table) + huge = is_vm_area_hugepages(table); } else { /* * If bucketsize is not a power-of-two, we may free