]> Gentwo Git Trees - linux/.git/commit
kho: make sure page being restored is actually from KHO
authorPratyush Yadav <pratyush@kernel.org>
Wed, 17 Sep 2025 12:56:54 +0000 (14:56 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 23 Sep 2025 21:14:17 +0000 (14:14 -0700)
commit89a3ecca49ee889cc1ab4def6caa0452df196efb
treee046ee6fb61d80996c33c7c8c7ce58ce054f17f6
parent20571b187051e5b78b48b99c9bdd425c94b29e18
kho: make sure page being restored is actually from KHO

When restoring a page, no sanity checks are done to make sure the page
actually came from a kexec handover.  The caller is trusted to pass in the
right address.  If the caller has a bug and passes in a wrong address, an
in-use page might be "restored" and returned, causing all sorts of memory
corruption.

Harden the page restore logic by stashing in a magic number in
page->private along with the order.  If the magic number does not match,
the page won't be touched.  page->private is an unsigned long.  The union
kho_page_info splits it into two parts, with one holding the order and the
other holding the magic number.

Link: https://lkml.kernel.org/r/20250917125725.665-2-pratyush@kernel.org
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
Cc: Alexander Graf <graf@amazon.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Changyuan Lyu <changyuanl@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/kexec_handover.c