From patchwork Tue Sep 23 17:27:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 4958521 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5A37DBEEA5 for ; Tue, 23 Sep 2014 17:29:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F23C2016C for ; Tue, 23 Sep 2014 17:29:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C6782025A for ; Tue, 23 Sep 2014 17:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753654AbaIWR3K (ORCPT ); Tue, 23 Sep 2014 13:29:10 -0400 Received: from canardo.mork.no ([148.122.252.1]:55777 "EHLO canardo.mork.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbaIWR3K (ORCPT ); Tue, 23 Sep 2014 13:29:10 -0400 Received: from nemi.mork.no (nemi.mork.no [IPv6:2001:4641:0:2:e8b:fdff:fe08:971]) (authenticated bits=0) by canardo.mork.no (8.14.4/8.14.4) with ESMTP id s8NHR6Fn003803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Tue, 23 Sep 2014 19:27:07 +0200 Received: from bjorn by nemi.mork.no with local (Exim 4.80) (envelope-from ) id 1XWTrm-0001QW-R6; Tue, 23 Sep 2014 19:27:06 +0200 From: =?utf-8?Q?Bj=C3=B8rn_Mork?= To: "Rafael J. Wysocki" Cc: linux-pm@vger.kernel.org Subject: Re: NULL pointer dereference in swsusp_free with 3.17-rc5 Organization: m References: <87zjdq8k7i.fsf@nemi.mork.no> <2218322.ridXK8jFtJ@vostro.rjw.lan> Date: Tue, 23 Sep 2014 19:27:06 +0200 In-Reply-To: <2218322.ridXK8jFtJ@vostro.rjw.lan> (Rafael J. Wysocki's message of "Tue, 23 Sep 2014 17:24:46 +0200") Message-ID: <878ulaxn6d.fsf@nemi.mork.no> User-Agent: Gnus/5.130011 (Ma Gnus v0.11) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.3.9 (canardo.mork.no [IPv6:2001:4641::1]); Tue, 23 Sep 2014 19:27:07 +0200 (CEST) X-Virus-Scanned: clamav-milter 0.98.4 at canardo X-Virus-Status: Clean Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP "Rafael J. Wysocki" writes: > I would suspect one of these commits: > > 84c91b7ae07c PM / hibernate: avoid unsafe pages in e820 reserved regions > 0f7d83e85dbd PM / Hibernate: Touch Soft Lockup Watchdog in rtree_next_node > 9047eb629e5c PM / Hibernate: Remove the old memory-bitmap implementation > 6efde38f0769 PM / Hibernate: Iterate over set bits instead of PFNs in swsusp_free() > 3a20cb177961 PM / Hibernate: Implement position keeping in radix tree > 07a338236fdc PM / Hibernate: Add memory_rtree_find_bit function > f469f02dc6fa PM / Hibernate: Create a Radix-Tree to store memory bitmap > > so I guess you can start from checking them (the topmpost one is the latest). Thanks. Yes, you were correct. The bad commit is 6efde38f0769 PM / Hibernate: Iterate over set bits instead of PFNs in swsusp_free() I have confirmed that reverting only this commit on top of a clean v3.17-rc6 fixes the problem. I am attaching the context-modified revert patch I used. Bjørn From 92950fd86c2f74ae17840bfc15651b6ae77e43df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Tue, 23 Sep 2014 19:18:43 +0200 Subject: [PATCH] Revert "PM / Hibernate: Iterate over set bits instead of PFNs in swsusp_free()" This reverts commit 6efde38f07690652bf0d93f5e4f1a5f496574806. Conflicts: kernel/power/snapshot.c --- kernel/power/snapshot.c | 50 ++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index c4b8093c80b3..f1604d8cf489 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -725,14 +725,6 @@ static void memory_bm_clear_bit(struct memory_bitmap *bm, unsigned long pfn) clear_bit(bit, addr); } -static void memory_bm_clear_current(struct memory_bitmap *bm) -{ - int bit; - - bit = max(bm->cur.node_bit - 1, 0); - clear_bit(bit, bm->cur.node->data); -} - static int memory_bm_test_bit(struct memory_bitmap *bm, unsigned long pfn) { void *addr; @@ -1341,35 +1333,23 @@ static struct memory_bitmap copy_bm; void swsusp_free(void) { - unsigned long fb_pfn, fr_pfn; - - memory_bm_position_reset(forbidden_pages_map); - memory_bm_position_reset(free_pages_map); - -loop: - fr_pfn = memory_bm_next_pfn(free_pages_map); - fb_pfn = memory_bm_next_pfn(forbidden_pages_map); - - /* - * Find the next bit set in both bitmaps. This is guaranteed to - * terminate when fb_pfn == fr_pfn == BM_END_OF_MAP. - */ - do { - if (fb_pfn < fr_pfn) - fb_pfn = memory_bm_next_pfn(forbidden_pages_map); - if (fr_pfn < fb_pfn) - fr_pfn = memory_bm_next_pfn(free_pages_map); - } while (fb_pfn != fr_pfn); - - if (fr_pfn != BM_END_OF_MAP && pfn_valid(fr_pfn)) { - struct page *page = pfn_to_page(fr_pfn); + struct zone *zone; + unsigned long pfn, max_zone_pfn; - memory_bm_clear_current(forbidden_pages_map); - memory_bm_clear_current(free_pages_map); - __free_page(page); - goto loop; + for_each_populated_zone(zone) { + max_zone_pfn = zone_end_pfn(zone); + for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) + if (pfn_valid(pfn)) { + struct page *page = pfn_to_page(pfn); + + if (swsusp_page_is_forbidden(page) && + swsusp_page_is_free(page)) { + swsusp_unset_page_forbidden(page); + swsusp_unset_page_free(page); + __free_page(page); + } + } } - nr_copy_pages = 0; nr_meta_pages = 0; restore_pblist = NULL; -- 1.7.10.4