mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] arm64: hibernate: check pgd table allocation
@ 2019-10-14 14:48 Pavel Tatashin
  2019-10-14 14:53 ` Pavel Tatashin
  2019-10-14 17:58 ` James Morse
  0 siblings, 2 replies; 3+ messages in thread
From: Pavel Tatashin @ 2019-10-14 14:48 UTC (permalink / raw)
  To: pasha.tatashin, jmorris, sashal, linux-kernel, catalin.marinas,
	will, steve.capper, linux-arm-kernel, marc.zyngier, james.morse,
	vladimir.murzin, mark.rutland, tglx

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: 82869ac57b5d ("arm64: kernel: Add support for hibernate/suspend-to-disk")

Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
---
 arch/arm64/kernel/hibernate.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
index e0a7fce0e01c..a96b2921d22c 100644
--- a/arch/arm64/kernel/hibernate.c
+++ b/arch/arm64/kernel/hibernate.c
@@ -201,6 +201,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
 				 gfp_t mask)
 {
 	int rc = 0;
+	pgd_t *trans_pgd;
 	pgd_t *pgdp;
 	pud_t *pudp;
 	pmd_t *pmdp;
@@ -215,7 +216,13 @@ static int create_safe_exec_page(void *src_start, size_t length,
 	memcpy((void *)dst, src_start, 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))) {
 		pudp = allocator(mask);
 		if (!pudp) {
-- 
2.23.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: hibernate: check pgd table allocation
  2019-10-14 14:48 [PATCH] arm64: hibernate: check pgd table allocation Pavel Tatashin
@ 2019-10-14 14:53 ` Pavel Tatashin
  2019-10-14 17:58 ` James Morse
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Tatashin @ 2019-10-14 14:53 UTC (permalink / raw)
  To: jmorris, sashal, linux-kernel, catalin.marinas, will,
	steve.capper, linux-arm-kernel, marc.zyngier, james.morse,
	vladimir.murzin, mark.rutland, tglx

On 19-10-14 10:48:24, Pavel Tatashin wrote:
> 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: 82869ac57b5d ("arm64: kernel: Add support for hibernate/suspend-to-disk")
> 
> Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>

Forgot to include nit from James Morse: remove empty lines between tags.
If required, I will send out an updated patch, otherwise it can be taken
as is.

Thank you,
Pasha

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: hibernate: check pgd table allocation
  2019-10-14 14:48 [PATCH] arm64: hibernate: check pgd table allocation Pavel Tatashin
  2019-10-14 14:53 ` Pavel Tatashin
@ 2019-10-14 17:58 ` James Morse
  1 sibling, 0 replies; 3+ messages in thread
From: James Morse @ 2019-10-14 17:58 UTC (permalink / raw)
  To: Pavel Tatashin
  Cc: jmorris, sashal, linux-kernel, catalin.marinas, will,
	steve.capper, linux-arm-kernel, marc.zyngier, vladimir.murzin,
	mark.rutland, tglx

Hi Pavel,

On 14/10/2019 15:48, Pavel Tatashin wrote:
> 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: 82869ac57b5d ("arm64: kernel: Add support for hibernate/suspend-to-disk")
> 
> Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
> ---

Reviewed-by: James Morse <james.morse@arm.com>


Thanks,

James

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-14 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 14:48 [PATCH] arm64: hibernate: check pgd table allocation Pavel Tatashin
2019-10-14 14:53 ` Pavel Tatashin
2019-10-14 17:58 ` James Morse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®