PM: hibernate: fix crashes with init_on_free=1
authorAlexander Potapenko <glider@google.com>
Thu, 16 Jan 2020 11:09:34 +0000 (12:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jan 2020 15:45:25 +0000 (16:45 +0100)
commitb1302cbe530b26ce6ba4a1a4019513393a566f6f
tree7bf85717138a4a1faf67af0bdda0bef3e9cb3fa6
parentd63b777d8145d351d1e8f991156a98fe51bea964
PM: hibernate: fix crashes with init_on_free=1

commit 18451f9f9e5810b8bd1245c5ae166f257e0e2b9d upstream.

Upon resuming from hibernation, free pages may contain stale data from
the kernel that initiated the resume. This breaks the invariant
inflicted by init_on_free=1 that freed pages must be zeroed.

To deal with this problem, make clear_free_pages() also clear the free
pages when init_on_free is enabled.

Fixes: 6471384af2a6 ("mm: security: introduce init_on_alloc=1 and init_on_free=1 boot options")
Reported-by: Johannes Stezenbach <js@sig21.net>
Signed-off-by: Alexander Potapenko <glider@google.com>
Cc: 5.3+ <stable@vger.kernel.org> # 5.3+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/power/snapshot.c