Skip to content

[PW_SID:1121918] [v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()#2216

Closed
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1121918
Closed

[PW_SID:1121918] [v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()#2216
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1121918

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

PR for series 1121918 applied to workflow__riscv__fixes

Name: [v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1121918
Version: 5

Linux RISC-V bot and others added 2 commits July 1, 2026 03:48
A NULL pointer dereference issue is noticed in riscv's machine_kexec_prepare(),
where image->segment[i].buf might be NULL and copied unchecked.

The NULL buf comes from ima_add_kexec_buffer(), where kbuf is added by
kexec_add_buffer(), but kbuf.buffer is NULL, then it is copied without
a check in machine_kexec_prepare():

  kexec_file_load
    -> kimage_file_alloc_init()
       -> kimage_file_prepare_segments()
          -> ima_add_kexec_buffer()
             -> kexec_add_buffer()
    -> machine_kexec_prepare()
       -> memcpy()

Address this by adding a check before the data copy attempt.

Fixes: b7fb4d7 ("RISC-V: use memcpy for kexec_file mode")
Cc: stable@vger.kernel.org
Closes: https://lore.kernel.org/kexec/CAO7dBbVftLUhd2qrh7hmijTB3PEPfZAhykCGqEfrPoOcSrrj-w@mail.gmail.com/
Acked-by: Baoquan He <bhe@redhat.com>
Acked-by: Pratyush Yadav <pratyush@kernel.org>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 144.85 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1395.77 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1724.90 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 28.45 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 30.21 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.80 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 87.37 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
kdoc
Desc: Detects for kdoc errors
Duration: 0.88 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v5] riscv: Prevent NULL pointer dereference in machine_kexec_prepare()"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot force-pushed the workflow__riscv__fixes branch from 89be0ce to dc5ff20 Compare July 7, 2026 03:25
@linux-riscv-bot
linux-riscv-bot deleted the pw1121918 branch July 7, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants