linux/drivers/acpi/nfit
Suraj Sonawane 265e98f72b acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl
Fix an issue detected by syzbot with KASAN:

BUG: KASAN: vmalloc-out-of-bounds in cmd_to_func drivers/acpi/nfit/
core.c:416 [inline]
BUG: KASAN: vmalloc-out-of-bounds in acpi_nfit_ctl+0x20e8/0x24a0
drivers/acpi/nfit/core.c:459

The issue occurs in cmd_to_func when the call_pkg->nd_reserved2
array is accessed without verifying that call_pkg points to a buffer
that is appropriately sized as a struct nd_cmd_pkg. This can lead
to out-of-bounds access and undefined behavior if the buffer does not
have sufficient space.

To address this, a check was added in acpi_nfit_ctl() to ensure that
buf is not NULL and that buf_len is less than sizeof(*call_pkg)
before accessing it. This ensures safe access to the members of
call_pkg, including the nd_reserved2 array.

Reported-by: syzbot+7534f060ebda6b8b51b3@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7534f060ebda6b8b51b3
Tested-by: syzbot+7534f060ebda6b8b51b3@syzkaller.appspotmail.com
Fixes: ebe9f6f19d ("acpi/nfit: Fix bus command validation")
Signed-off-by: Suraj Sonawane <surajsonawane0215@gmail.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20241118162609.29063-1-surajsonawane0215@gmail.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
2024-12-04 14:58:44 -06:00
..
core.c acpi: nfit: vmalloc-out-of-bounds Read in acpi_nfit_ctl 2024-12-04 14:58:44 -06:00
intel.c nvdimm/region: Move cache management to the region driver 2022-12-02 23:52:32 -08:00
intel.h ACPI: NFIT: Add runtime firmware activate support 2020-07-28 19:29:22 -06:00
Kconfig acpi/nfit: Add support for Intel DSM 1.8 commands 2018-12-04 10:31:11 -08:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mce.c acpi/nfit: rely on mce->misc to determine poison granularity 2022-05-16 11:46:44 -07:00
nfit.h ACPI: NFIT: Add declaration in a local header 2023-06-05 19:06:20 +02:00