Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp461583yba; Wed, 15 May 2019 04:31:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3qfoQp4i5xLMAkwji9x1CKquy4f+7D9okZN0LJ2X5Al+cSiD88565mbrGZMYaWg9c+11B X-Received: by 2002:a63:555a:: with SMTP id f26mr44131399pgm.197.1557919906651; Wed, 15 May 2019 04:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557919906; cv=none; d=google.com; s=arc-20160816; b=OIp8b+9vZtVAZIhFrmuykYcbAP0cPpprDW2MykQyqHeBx/vyAowYwRE4eKpOUWEREK yeat62aDzyNv1sAvLMgtn7qWQuEkWLDQ9TrKFbOGRhorB8S06IZV9g7XTnATzu6yNkRR 5JMSjOhbsAqM/FXChd6fEe8SjeCo0D6YAeIouhQrCIy8K0sO3L//SmBXoI2QKCla2A+H g+moqVMvzR3UAuiqxWa4ArunfAr3L1ZR5LokDIgd7TmQu/c0ORxRGRG1394b64sVsIsu BBQdWmezfqCECqfcv3K2Ab/L0HAWxDBVC5d5cNVN7617r/Fc6cutngO+3lJryTnvXNtx 6/lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m48XS08uBUZauBdUtuh2Qrrn1gkRtRjKRUm5e9tosGQ=; b=E4xiYtgjbe0s5dReaWQ5FVC8SBmy+m64V/jrlkvrPBuw/DQuqxFHHbkx+6ZE6YGfyC oKgrXFiUOsdXrz/x/1WT5zdbAduKewWp52tCkI+0MSDNWhYxCYTrGmt8v2vJfyyRdJrR tsVFEVioZJWbRBG7UtFNKZm7OjG1Q8sdq73bHXCAMDaHpw+8PSl3xUjopNMegNi2JmA4 ywrZ31n5UkW5ZJuGDNL7XK7P7uQyf5yBN8bqpQghh3K83NOLeUkClhlAQdbXZuXvZaf5 pXv+DTQQcuVaEbZB0srgBOFCTZ7TTb2QwsN7Ennr+egE/hX1fap82k43e+6E9JYTC57H bf2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gsMIWM2q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h68si1662237pgc.270.2019.05.15.04.31.31; Wed, 15 May 2019 04:31:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gsMIWM2q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732653AbfEOLaB (ORCPT + 99 others); Wed, 15 May 2019 07:30:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:41298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726589AbfEOL3z (ORCPT ); Wed, 15 May 2019 07:29:55 -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 A5A74206BF; Wed, 15 May 2019 11:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919794; bh=A2HWa2eMV8cNpLlt3TpLLCMT1YnL9BzX46XVNAsJMbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gsMIWM2qtrzIN07IT2uJdI7FyOpBP6H6AOeV1nvLrZ2mtWfJDEXkpZKxp2T9XkJXq e6qBs+exVuDuV9f0eSvuu2l1ZDqSzHzf78N/CawTx4O+Duq+s/C3YIGdfXVrEoVXEx ccYIQLhhRBHCUsJ1ZhZ+gsQrKOzo0vCb4eK3oZ+o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Ryabinin , Mel Gorman , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.0 096/137] mm/page_alloc.c: avoid potential NULL pointer dereference Date: Wed, 15 May 2019 12:56:17 +0200 Message-Id: <20190515090700.506837533@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090651.633556783@linuxfoundation.org> References: <20190515090651.633556783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8139ad043d632c0e9e12d760068a7a8e91659aa1 ] ac.preferred_zoneref->zone passed to alloc_flags_nofragment() can be NULL. 'zone' pointer unconditionally derefernced in alloc_flags_nofragment(). Bail out on NULL zone to avoid potential crash. Currently we don't see any crashes only because alloc_flags_nofragment() has another bug which allows compiler to optimize away all accesses to 'zone'. Link: http://lkml.kernel.org/r/20190423120806.3503-1-aryabinin@virtuozzo.com Fixes: 6bb154504f8b ("mm, page_alloc: spread allocations across zones before introducing fragmentation") Signed-off-by: Andrey Ryabinin Acked-by: Mel Gorman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index eedb57f9b40b5..d59be95ba45cf 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3385,6 +3385,9 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) alloc_flags |= ALLOC_KSWAPD; #ifdef CONFIG_ZONE_DMA32 + if (!zone) + return alloc_flags; + if (zone_idx(zone) != ZONE_NORMAL) goto out; -- 2.20.1