riscv: Prevent NULL pointer dereference in machine_kexec_prepare()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ b7fb4d78a6ade6026d9e5cf438c2a46ab962e032 · < d5b2752a17efc165793ae38f2c24b5ed9c04ffde| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
riscv: Prevent NULL pointer dereference in machine_kexec_prepare()
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.
From the CVE record · Linux
The Linux kernel’s RISC-V machine_kexec_prepare() can dereference a NULL pointer when an IMA kexec buffer is NULL and is copied without a check. This can occur during kexec_file_load(); the input does not specify attacker access requirements or user interaction.
Engineers running the Linux kernel on RISC-V should check their deployments; affected versions are not specified.