From 443b5c366694650f9c771863556433270fff8bc2 Mon Sep 17 00:00:00 2001 From: Suraj Sonawane Date: Sun, 10 Nov 2024 16:01:24 +0530 Subject: [PATCH v3] KASAN: vmalloc-out-of-bounds Read in acpi_nfit_ctl (2) syz test Signed-off-by: Suraj Sonawane --- drivers/acpi/nfit/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 5429ec9ef..4a2997b60 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -454,8 +454,13 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, if (cmd_rc) *cmd_rc = -EINVAL; - if (cmd == ND_CMD_CALL) - call_pkg = buf; + if (cmd == ND_CMD_CALL) { + if (buf == NULL || buf_len < sizeof(struct nd_cmd_pkg)) { + rc = -EINVAL; + goto out; + } + call_pkg = (struct nd_cmd_pkg *)buf; + } func = cmd_to_func(nfit_mem, cmd, call_pkg, &family); if (func < 0) return func; -- 2.34.1