From e876377b1ada7e1270a3a63b4d19cbe35c78f904 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 11 Aug 2010 16:04:31 -0700 Subject: [PATCH] .32 patches --- ...-by-reusing-swap-during-image-saving.patch | 72 +++++++++++++++++++ queue-2.6.32/series | 1 + 2 files changed, 73 insertions(+) create mode 100644 queue-2.6.32/mm-fix-corruption-of-hibernation-caused-by-reusing-swap-during-image-saving.patch diff --git a/queue-2.6.32/mm-fix-corruption-of-hibernation-caused-by-reusing-swap-during-image-saving.patch b/queue-2.6.32/mm-fix-corruption-of-hibernation-caused-by-reusing-swap-during-image-saving.patch new file mode 100644 index 00000000000..f66c5cfc70f --- /dev/null +++ b/queue-2.6.32/mm-fix-corruption-of-hibernation-caused-by-reusing-swap-during-image-saving.patch @@ -0,0 +1,72 @@ +From hughd@google.com Wed Aug 11 16:03:09 2010 +Date: Wed, 11 Aug 2010 15:32:15 -0700 (PDT) +From: KAMEZAWA Hiroyuki +To: Greg KH +cc: gregkh@suse.de, kamezawa.hiroyu@jp.fujitsu.com, akpm@linux-foundation.org, + andrea.gelmini@gmail.com, linux@rainbow-software.org, rjw@sisk.pl, + torvalds@linux-foundation.org, stable@kernel.org, + stable-commits@vger.kernel.org +Subject: mm: fix corruption of hibernation caused by reusing swap during image saving +Message-ID: + +From: KAMEZAWA Hiroyuki + +commit 966cca029f739716fbcc8068b8c6dfe381f86fc3 upstream. + +Since 2.6.31, swap_map[]'s refcounting was changed to show that a used +swap entry is just for swap-cache, can be reused. Then, while scanning +free entry in swap_map[], a swap entry may be able to be reclaimed and +reused. It was caused by commit c9e444103b5e7a5 ("mm: reuse unused swap +entry if necessary"). + +But this caused deta corruption at resume. The scenario is + +- Assume a clean-swap cache, but mapped. + +- at hibernation_snapshot[], clean-swap-cache is saved as + clean-swap-cache and swap_map[] is marked as SWAP_HAS_CACHE. + +- then, save_image() is called. And reuse SWAP_HAS_CACHE entry to save + image, and break the contents. + +After resume: + +- the memory reclaim runs and finds clean-not-referenced-swap-cache and + discards it because it's marked as clean. But here, the contents on + disk and swap-cache is inconsistent. + +Hance memory is corrupted. + +This patch avoids the bug by not reclaiming swap-entry during hibernation. +This is a quick fix for backporting. + +Signed-off-by: KAMEZAWA Hiroyuki +Cc: Rafael J. Wysocki +Reported-by: Ondreg Zary +Tested-by: Ondreg Zary +Tested-by: Andrea Gelmini +Signed-off-by: Hugh Dickins +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + + +--- + mm/swapfile.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +--- a/mm/swapfile.c ++++ b/mm/swapfile.c +@@ -330,8 +330,10 @@ checks: + if (offset > si->highest_bit) + scan_base = offset = si->lowest_bit; + +- /* reuse swap entry of cache-only swap if not busy. */ +- if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) { ++ /* reuse swap entry of cache-only swap if not hibernation. */ ++ if (vm_swap_full() ++ && cache == SWAP_CACHE ++ && si->swap_map[offset] == SWAP_HAS_CACHE) { + int swap_was_freed; + spin_unlock(&swap_lock); + swap_was_freed = __try_to_reclaim_swap(si, offset); diff --git a/queue-2.6.32/series b/queue-2.6.32/series index 3eb261dfe89..c8a379a503d 100644 --- a/queue-2.6.32/series +++ b/queue-2.6.32/series @@ -108,3 +108,4 @@ aic79xx-check-for-non-null-scb-in-ahd_handle_nonpkt_busfree.patch ibmvfc-fix-command-completion-handling.patch ibmvfc-reduce-error-recovery-timeout.patch md-raid1-delay-reads-that-could-overtake-behind-writes.patch +mm-fix-corruption-of-hibernation-caused-by-reusing-swap-during-image-saving.patch -- 2.47.3