Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932324AbcDLIDz (ORCPT ); Tue, 12 Apr 2016 04:03:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:35900 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751181AbcDLIDv (ORCPT ); Tue, 12 Apr 2016 04:03:51 -0400 Subject: Re: mmotm woes, mainly compaction To: Hugh Dickins , Michal Hocko References: Cc: Andrew Morton , Michal Hocko , linux-kernel@vger.kernel.org, linux-mm@kvack.org From: Vlastimil Babka Message-ID: <570CABE3.4070404@suse.cz> Date: Tue, 12 Apr 2016 10:03:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1876 Lines: 49 On 04/12/2016 09:18 AM, Hugh Dickins wrote: > 2. Fix crash in get_pfnblock_flags_mask() from suitable_migration_target() > from isolate_freepages(): 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[]. (I have not worked out > why this never hit me before 4.6-rc2-mm1, it looks much older.) This is actually my fresh mmotm bug, thanks for catching that! Fix for: mm-compaction-wrap-calculating-first-and-last-pfn-of-pageblock.patch ----8<---- >From 45330dfb350d6b3bc72bcdaccc226bcc286e1236 Mon Sep 17 00:00:00 2001 From: Vlastimil Babka Date: Tue, 12 Apr 2016 09:54:33 +0200 Subject: [PATCH] mm, compaction: fix crash in get_pfnblock_flags_mask() from isolate_freepages(): 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[]. 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 315e5d57e7e9..67f886ecd773 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1012,7 +1012,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