Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932785AbcDYNgv (ORCPT ); Mon, 25 Apr 2016 09:36:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:41969 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932415AbcDYNf5 (ORCPT ); Mon, 25 Apr 2016 09:35:57 -0400 From: Vlastimil Babka To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Joonsoo Kim , Hugh Dickins , Rik van Riel , Vlastimil Babka Subject: [PATCH mmotm 2/3] mm, compaction: fix crash in get_pfnblock_flags_mask() from isolate_freepages(): Date: Mon, 25 Apr 2016 15:35:49 +0200 Message-Id: <1461591350-28700-3-git-send-email-vbabka@suse.cz> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1461591350-28700-1-git-send-email-vbabka@suse.cz> References: <1461591269-28615-1-git-send-email-vbabka@suse.cz> <1461591350-28700-1-git-send-email-vbabka@suse.cz> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1128 Lines: 30 In isolate_freepages(), low_pfn was mistakenly initialized to pageblock_start_pfn() instead of pageblock_end_pfn(), creating a possible underflow, as described by Hugh: There's a case when that "block_start_pfn -= pageblock_nr_pages" loop can pass through 0 and end up trying to access a pageblock before the start of the mem_map[]. Fixes: mmotm mm-compaction-wrap-calculating-first-and-last-pfn-of-pageblock.patch Reported-by: Hugh Dickins Signed-off-by: Vlastimil Babka --- mm/compaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/compaction.c b/mm/compaction.c index 759c3ac73ced..6a49d1b35515 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -999,7 +999,7 @@ static void isolate_freepages(struct compact_control *cc) block_start_pfn = pageblock_start_pfn(cc->free_pfn); block_end_pfn = min(block_start_pfn + pageblock_nr_pages, zone_end_pfn(zone)); - low_pfn = pageblock_start_pfn(cc->migrate_pfn); + low_pfn = pageblock_end_pfn(cc->migrate_pfn); /* * Isolate free pages until enough are available to migrate the -- 2.8.1