linux-stable/kernel/power
Andy Whitcroft 76548ddc1b PM / hibernate: memory_bm_find_bit(): Tighten node optimisation
[ Upstream commit da6043fe85 ]

When looking for a bit by number we make use of the cached result from the
preceding lookup to speed up operation.  Firstly we check if the requested
pfn is within the cached zone and if not lookup the new zone.  We then
check if the offset for that pfn falls within the existing cached node.
This happens regardless of whether the node is within the zone we are
now scanning.  With certain memory layouts it is possible for this to
false trigger creating a temporary alias for the pfn to a different bit.
This leads the hibernation code to free memory which it was never allocated
with the expected fallout.

Ensure the zone we are scanning matches the cached zone before considering
the cached node.

Deep thanks go to Andrea for many, many, many hours of hacking and testing
that went into cornering this bug.

Reported-by: Andrea Righi <andrea.righi@canonical.com>
Tested-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-09 10:18:58 +01:00
..
autosleep.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
console.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hibernate.c x86/power: Fix 'nosmt' vs hibernation triple fault during resume 2019-06-11 12:20:52 +02:00
Kconfig PM / sleep: wakeup: Fix build error caused by missing SRCU support 2018-08-15 00:07:08 +02:00
main.c PM / reboot: Eliminate race between reboot and suspend 2018-08-06 12:35:20 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
power.h x86/power: Fix swsusp_arch_resume prototype 2018-02-02 23:33:50 +01:00
poweroff.c power/sysrq: fix inconstistent help message of sysrq key 2013-04-30 17:04:10 -07:00
process.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
qos.c PM / QoS: Drop redundant declaration of pm_qos_get_value() 2018-05-28 23:21:41 +02:00
snapshot.c PM / hibernate: memory_bm_find_bit(): Tighten node optimisation 2020-01-09 10:18:58 +01:00
suspend.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2018-10-12 12:35:02 +02:00
suspend_test.c PM / s2idle: Rename PM_SUSPEND_FREEZE to PM_SUSPEND_TO_IDLE 2017-08-11 01:29:55 +02:00
swap.c PM / hibernate: cast PAGE_SIZE to int when comparing with error code 2018-07-02 11:48:30 +02:00
user.c PM / reboot: Eliminate race between reboot and suspend 2018-08-06 12:35:20 +02:00
wakelock.c PM / wakeup: Only update last time for active wakeup sources 2018-05-10 11:39:19 +02:00