Skip to content

[PW_SID:1119364] [v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare#2179

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

[PW_SID:1119364] [v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare#2179
linux-riscv-bot wants to merge 2 commits into
workflow__riscv__fixesfrom
pw1119364

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

PR for series 1119364 applied to workflow__riscv__fixes

Name: [v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1119364
Version: 3

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 security/integrity/ima/ima_kexec.c:
ima_add_kexec_buffer(), where kbuf is added by kexec_add_buffer(),
but kbuf.buffer is NULL.

Fix this by simply adding a check before copy.

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

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 119.72 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a 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: 1368.56 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a 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: 1712.15 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 21.71 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 23.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.49 seconds
Result: WARNING
Output:

CHECK: Comparison to NULL could be written "!image->segment[i].buf"
#38: FILE: arch/riscv/kernel/machine_kexec.c:48:
+		if (image->segment[i].buf == NULL)

total: 0 errors, 0 warnings, 1 checks, 13 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 10e7e73c8f52 ("riscv: Fix a NULL pointer dereference in machine_kexec_prepare") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 1 checks, 13 lines checked
CHECK: Comparison to NULL could be written "!image->segment[i].buf"


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 79.43 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.21 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
kdoc
Desc: Detects for kdoc errors
Duration: 0.70 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v3] riscv: Fix a NULL pointer dereference in machine_kexec_prepare"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot force-pushed the workflow__riscv__fixes branch 3 times, most recently from a50938c to 40ba5ca Compare July 8, 2026 17:32
@linux-riscv-bot
linux-riscv-bot deleted the pw1119364 branch July 9, 2026 13:52
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