]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
PM / hibernate: memory_bm_find_bit(): Tighten node optimisation
authorAndy Whitcroft <apw@canonical.com>
Wed, 25 Sep 2019 14:39:12 +0000 (15:39 +0100)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 18 Oct 2019 08:25:38 +0000 (04:25 -0400)
commit4c6fcb373e32137e7e765742d44c087688034c25
treee6baa23dfbf211d21ca77e3600ca7702bb7ef7db
parente98e18d5c5d9d76496dbcba8b724d6a57c815114
PM / hibernate: memory_bm_find_bit(): Tighten node optimisation

BugLink: https://bugs.launchpad.net/bugs/1847118
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>
(cherry picked from commit 39800d8fc4083cfe5c8f69333336bf03f9571070 linux-next)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Acked-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
kernel/power/snapshot.c