From patchwork Tue Apr 23 12:08:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 10912845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34B68922 for ; Tue, 23 Apr 2019 12:07:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2408E28754 for ; Tue, 23 Apr 2019 12:07:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 145C128861; Tue, 23 Apr 2019 12:07:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B19428754 for ; Tue, 23 Apr 2019 12:07:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB9A36B0003; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A67D96B0007; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96A9A6B0008; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by kanga.kvack.org (Postfix) with ESMTP id 4D0636B0003 for ; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) Received: by mail-lj1-f198.google.com with SMTP id j8so2337336lja.11 for ; Tue, 23 Apr 2019 05:07:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:mime-version:content-transfer-encoding; bh=T857UWl4vW/mMLkowhYpmmGUf62PJOrVKCTWr9tpU4g=; b=JzMe3FlFIpNSl6ghsjK2Ayy8p/bH8NVESs9uZHU9eO+3rC0RRR8YPvj1U9KEa22CEh ImVFOJaw9FyOg5wIiIie+toFEGSlnHKqteKfWrw/UPP3Dr2FysY9eDB1B/lIWGK26xcO I8eaxLX6eHiO5AVV9S/dO43dBuNLvF58KD3tkpLh1uOEsbSqTFT/TTcchegrWQt2o9a7 nCb9c9xttbX4jTOAqq6VAp63SQzp/fFMt9qm6W48FNbFsmOVgq1/v3TmXNxj95nLsk/l w2GhAJ8cXMwYUJ6VFr1zG7FkwR30m2zGYvmBr4fVw2e0wno5ctdK4pCofAp9gRO8y0KX f0pA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=aryabinin@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: APjAAAUk9XHajdQbjM1Nt+WxLd9sHV6VIs1uBY3lNVztrMRsbxBJXRpa pUpidovDjAjn9at2u04y6OrKzklEJpWhskBExphPwlVrNiHeeDWJDeVwRzborhB7p8GD8f+5RAY TlvhHigbsz6Jc9YT8Ap4t6L0aLCFfQdjL0a+0RH++BpSjaBjPKntnqpnreeeM/elUmA== X-Received: by 2002:a2e:8794:: with SMTP id n20mr14083809lji.76.1556021263587; Tue, 23 Apr 2019 05:07:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqza+dm4C7Y+IqZEopa7k2+WHLDRXPVXCgdUrp3KGkqSi4xWWkCDhiP/mIl88tmHfeSzEdIE X-Received: by 2002:a2e:8794:: with SMTP id n20mr14083761lji.76.1556021262449; Tue, 23 Apr 2019 05:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556021262; cv=none; d=google.com; s=arc-20160816; b=K+zJ8ulUvfSwScXhXaGx1yYzDOZzm2TY9fRv1/A50flZkU/SXJKJaxxmmENZYjbLX8 x4SzppBFtFBLEe4kSV4UJ2Rm3b+l/BkJN9qwKMPn03V4Ngy4nTo5mNCEvSBexqdxmSu2 zLs2JzyGph5sfUInjwDU5ztnhU+I5PuTAWvAJumre0uoJecsJt/j4CaL6YwKZZb1ELBs pxwGWozchGMvROuL/aQ6bGcnA29GujTDE0ULG06HLljMWzDX+jo3+Mzd+ZBXFd5JOjfh GNN9oTbGqaeuVK1AV61WqjQY974Zf/2A8NpLG6ptDSQPa8nI11OSi7UoX4MGdog6j+6r Fuvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=T857UWl4vW/mMLkowhYpmmGUf62PJOrVKCTWr9tpU4g=; b=YXBG+VAB+GC6JTIiloMVRLGswkIc4p+PVboMo9em/c+aq6NZvsvJUl4saH/8aq9oCa H4gV1uHLFEzwTiUmip5N07hz8YhQ0iW25pb4u4QOyEHmMY7c/RKEjHwdmAnILFA3Cvjs g0worpWeHJscWh4kZPNinZimAtntnSg5bLAuREWHh8v5Ca2gmrYFostv2CQar2Na55JW /YYRzLMX3qSP7sYdUnEV8gJckXqM2Tz5ygztuoqwgpFJzmq2JgLLRv60zsxSJr7deCy2 q/CL24bO9zEaepj8of9pkWiKNnlPplk+Wd0vYNVuPTjzq1XMzp1vjpTq04SqJhmkiyNj phSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=aryabinin@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id j10si11316307lja.107.2019.04.23.05.07.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 05:07:42 -0700 (PDT) Received-SPF: pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=aryabinin@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from [172.16.25.12] (helo=i7.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hIuD5-0000jI-Hi; Tue, 23 Apr 2019 15:07:39 +0300 From: Andrey Ryabinin To: Andrew Morton Cc: Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Ryabinin Subject: [PATCH 1/2] mm/page_alloc: avoid potential NULL pointer dereference Date: Tue, 23 Apr 2019 15:08:05 +0300 Message-Id: <20190423120806.3503-1-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP 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'. Fixes: 6bb154504f8b ("mm, page_alloc: spread allocations across zones before introducing fragmentation") Signed-off-by: Andrey Ryabinin Acked-by: Mel Gorman --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 933bd42899e8..2b2c7065102f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3461,6 +3461,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; From patchwork Tue Apr 23 12:08:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 10912847 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F064F922 for ; Tue, 23 Apr 2019 12:07:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E203128754 for ; Tue, 23 Apr 2019 12:07:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5CFA28861; Tue, 23 Apr 2019 12:07:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8022528754 for ; Tue, 23 Apr 2019 12:07:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED6F66B0006; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E85B86B0007; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D751B6B0008; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by kanga.kvack.org (Postfix) with ESMTP id 8CD866B0006 for ; Tue, 23 Apr 2019 08:07:44 -0400 (EDT) Received: by mail-lf1-f70.google.com with SMTP id n6so2457272lfe.1 for ; Tue, 23 Apr 2019 05:07:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=X0/+2BMi/4gWHNjoTTFh3N0tTHjFTWGReBAP9LdRGHM=; b=fRFHbq7dcTrmr/W5mNZT3YbKZDxo8aM6RXNO4y447WE1WSpTlUf7plxndzTUpPOo2d 2uKy+xII/ng6jOoGA8JksApwI22F97ICDkI+WYdEYIq3DA2UCOUCW2acNs2NvQJQRfYF TLOYHaOXpHHwNmHR4CNwRwtslgNCTx4mKSNGuiXKnBzGatDCQZiiuY6kTABFHu4iuc4t S38lzaha0tgHFZHMkFvl+EcVaJfSr25osv5RbxdgBYlraZVVd2ZXMACfDS5NLSu8x4I7 xnExdqd89MmHAAxriIQNPPWp0zao1nWaf66FCKZeqPh4UshrdZAXkzvdE3KM94s/fmdg 6J0w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=aryabinin@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com X-Gm-Message-State: APjAAAU/MRlpiE24X/IM/e/fV53Cb7ctQfhhPR8/vyDojQPBzYEWLmtz KgasB7tWDSmGvW2rYN2mTdrlT2ze1bIKXJNOOmU8G3pBs9fVJND/EqeuTCcKQJPm/dK8gtzI1Dk a6ZSn6W4OleyfsygZnR9RtJigO+ADYByVNlP7kICc4j+K6wEreu5khYy4AfOVjS5gtA== X-Received: by 2002:a2e:8648:: with SMTP id i8mr14084911ljj.166.1556021263886; Tue, 23 Apr 2019 05:07:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAjY4dTRezG+l/344ZZNdPWhZlIjaPSven+o90PcUsBKbhPBdOtNRaxoLfekhzvcoUxX2b X-Received: by 2002:a2e:8648:: with SMTP id i8mr14084854ljj.166.1556021262449; Tue, 23 Apr 2019 05:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556021262; cv=none; d=google.com; s=arc-20160816; b=DqB5ONB3iXYQPcJ6lLwZFLOQHLoMSntOwNL+E8d3BbRb35XdXdip4vr51b30jWYQxT C9Os0istPv2YlwRUc0W1AgnuQEyhSZo7vRwRqzPhpjnhMjkycXOHj3phTipnBCn+FIyT O5MpSKyKh22C+WwnhAja7H4O4XFnjGWoYcHGy9bslXeoWzPwnXy1cUO7S+AjURonEvsY bAVIXeTyvZCPbmy3Vo5ZzbDWvcdhSe7nc02iarZvhFs5B5wyUeP3iCgeo80yBPp67GFo fpcUP1OsX6911/2Q3wuKyEvoQwr/yYzx72ISZ/WYGHgZb8QflHc9/9xu23zF2RKTwi/H Un5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=X0/+2BMi/4gWHNjoTTFh3N0tTHjFTWGReBAP9LdRGHM=; b=vzCMHA7JP8Hsa2QS6CDm4cJYomx6FRO6fFLVfbwhmF9j6HDQQviXbso8K/HoPNeGkR oZpwwvlH9KVfRcx1uY6S928QTYLRmJUkQys7XuR9vNwwWgS/0WKIOYQJeWKbPGKpHdiL Tjx4R9s1KYoSYb4Y+OE5KtsxaLo2t5HyFNXNWkZXdLhvCh5mDwTzrWVFxfdG94c9/FQP HlOYLSHvIWCz895cUA6iZxtod463yS74rECLUXJdxXfds753y7FcCGoPx0vTsJ6VG4vb LDZ8pjio9IB42ww6YckprRHGu/t6dV93BvSeiE2bzdatMC/eLJOnPdbRMGP2PgyRkFuI sGdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=aryabinin@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from relay.sw.ru (relay.sw.ru. [185.231.240.75]) by mx.google.com with ESMTPS id c24si11662545ljd.53.2019.04.23.05.07.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 05:07:42 -0700 (PDT) Received-SPF: pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) client-ip=185.231.240.75; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aryabinin@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=aryabinin@virtuozzo.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: from [172.16.25.12] (helo=i7.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hIuD5-0000jI-Pt; Tue, 23 Apr 2019 15:07:39 +0300 From: Andrey Ryabinin To: Andrew Morton Cc: Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Ryabinin Subject: [PATCH 2/2] mm/page_alloc: fix never set ALLOC_NOFRAGMENT flag Date: Tue, 23 Apr 2019 15:08:06 +0300 Message-Id: <20190423120806.3503-2-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423120806.3503-1-aryabinin@virtuozzo.com> References: <20190423120806.3503-1-aryabinin@virtuozzo.com> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP Commit 0a79cdad5eb2 ("mm: use alloc_flags to record if kswapd can wake") removed setting of the ALLOC_NOFRAGMENT flag. Bring it back. Fixes: 0a79cdad5eb2 ("mm: use alloc_flags to record if kswapd can wake") Signed-off-by: Andrey Ryabinin Acked-by: Mel Gorman --- mm/page_alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2b2c7065102f..a85b8252c5ad 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3465,7 +3465,7 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) return alloc_flags; if (zone_idx(zone) != ZONE_NORMAL) - goto out; + return alloc_flags; /* * If ZONE_DMA32 exists, assume it is the one after ZONE_NORMAL and @@ -3474,9 +3474,9 @@ alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) */ BUILD_BUG_ON(ZONE_NORMAL - ZONE_DMA32 != 1); if (nr_online_nodes > 1 && !populated_zone(--zone)) - goto out; + return alloc_flags; -out: + alloc_flags |= ALLOC_NOFRAGMENT; #endif /* CONFIG_ZONE_DMA32 */ return alloc_flags; }