[PATCH RFC 2/4] sh/crash_dump: check ioremap() in copy_oldmem_page()

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


On Thu, 2026-11-12 at 17:37 +0100, Christian Brauner wrote:
> copy_oldmem_page() maps a page of the old kernel with ioremap() and
> copies from it without checking whether the mapping worked. If it
> didn't, the copy reads from an offset into the NULL page.
> 
> Return -ENOMEM like the other architectures do. read_from_oldmem()
> turns
> that into -EFAULT like any other short copy.
> 
> Fixes: 4d5ade5b29c6 ("sh: kdump support.")
> Cc: stable at vger.kernel.org
> Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>

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

> ---
>  arch/sh/kernel/crash_dump.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/sh/kernel/crash_dump.c
> b/arch/sh/kernel/crash_dump.c
> index 19ce6a950aaca..85c0e58f1a59f 100644
> --- a/arch/sh/kernel/crash_dump.c
> +++ b/arch/sh/kernel/crash_dump.c
> @@ -20,6 +20,9 @@ ssize_t copy_oldmem_page(struct iov_iter *iter,
> unsigned long pfn,
>  		return 0;
>  
>  	vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
> +	if (!vaddr)
> +		return -ENOMEM;
> +
>  	csize = copy_to_iter(vaddr + offset, csize, iter);
>  	iounmap(vaddr);
>  



More information about the kexec mailing list