Commit 8c551f91 authored by Pavel Tatashin's avatar Pavel Tatashin Committed by Will Deacon

arm64: hibernate: check pgd table allocation

There is a bug in create_safe_exec_page(), when page table is allocated
it is not checked that table is allocated successfully:

But it is dereferenced in: pgd_none(READ_ONCE(*pgdp)).  Check that
allocation was successful.

Fixes: 82869ac5 ("arm64: kernel: Add support for hibernate/suspend-to-disk")
Reviewed-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarPavel Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent ec52c713
...@@ -201,6 +201,7 @@ static int create_safe_exec_page(void *src_start, size_t length, ...@@ -201,6 +201,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
gfp_t mask) gfp_t mask)
{ {
int rc = 0; int rc = 0;
pgd_t *trans_pgd;
pgd_t *pgdp; pgd_t *pgdp;
pud_t *pudp; pud_t *pudp;
pmd_t *pmdp; pmd_t *pmdp;
...@@ -215,7 +216,13 @@ static int create_safe_exec_page(void *src_start, size_t length, ...@@ -215,7 +216,13 @@ static int create_safe_exec_page(void *src_start, size_t length,
memcpy((void *)dst, src_start, length); memcpy((void *)dst, src_start, length);
__flush_icache_range(dst, dst + length); __flush_icache_range(dst, dst + length);
pgdp = pgd_offset_raw(allocator(mask), dst_addr); trans_pgd = allocator(mask);
if (!trans_pgd) {
rc = -ENOMEM;
goto out;
}
pgdp = pgd_offset_raw(trans_pgd, dst_addr);
if (pgd_none(READ_ONCE(*pgdp))) { if (pgd_none(READ_ONCE(*pgdp))) {
pudp = allocator(mask); pudp = allocator(mask);
if (!pudp) { if (!pudp) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment