[PATCH RFC 1/4] powerpc/crash_dump: check ioremap_cache() in copy_oldmem_page()

Alexander Mikhalitsyn alex at amutable.com
Sun Nov 15 23:58:26 PST 2026


On Thu, 2026-11-12 at 17:37 +0100, Christian Brauner wrote:
> copy_oldmem_page() maps a page of the old kernel that isn't in the
> linear mapping with ioremap_cache() and copies from it without
> checking
> whether the mapping worked. If it didn't, the copy reads from an
> offset
> into the NULL page. That oopses unless the copy happens to be a user
> copy, whose exception table entries turn the fault into a short copy.
> 
> Return -ENOMEM like the other architectures do. read_from_oldmem()
> turns that into -EFAULT like any other short copy.
> 
> Reported-by: Chris Mason <mason at kernel.org>
> Fixes: 54c32021eb6f ("[PATCH] powerpc: Add arch-dependent
> copy_oldmem_page")
> Cc: stable at vger.kernel.org
> Reviewed-by: Breno Leitao <leitao at debian.org>
> Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>

Reviewed-by: Alexander Mikhalitsyn <alex at amutable.com>

> ---
>  arch/powerpc/kernel/crash_dump.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/crash_dump.c
> b/arch/powerpc/kernel/crash_dump.c
> index 103b6605dd68f..1543917bd3e1d 100644
> --- a/arch/powerpc/kernel/crash_dump.c
> +++ b/arch/powerpc/kernel/crash_dump.c
> @@ -86,6 +86,8 @@ ssize_t copy_oldmem_page(struct iov_iter *iter,
> unsigned long pfn,
>  		csize = copy_to_iter(vaddr + offset, csize, iter);
>  	} else {
>  		vaddr = ioremap_cache(paddr, PAGE_SIZE);
> +		if (!vaddr)
> +			return -ENOMEM;
>  		csize = copy_to_iter(vaddr + offset, csize, iter);
>  		iounmap(vaddr);
>  	}



More information about the kexec mailing list