Skip to content

Commit de436a7

Browse files
committed
acpi: nfit: fix narrowing conversion in acpi_nfit_ctl
JIRA: https://issues.redhat.com/browse/RHEL-114091 commit 2ff0e40 Author: Murad Masimov <m.masimov@mt-integration.ru> Date: Mon, 03 Mar 2025 08:03:43 +0000 Syzkaller has reported a warning in to_nfit_bus_uuid(): "only secondary bus families can be translated". This warning is emited if the argument is equal to NVDIMM_BUS_FAMILY_NFIT == 0. Function acpi_nfit_ctl() first verifies that a user-provided value call_pkg->nd_family of type u64 is not equal to 0. Then the value is converted to int, and only after that is compared to NVDIMM_BUS_FAMILY_MAX. This can lead to passing an invalid argument to acpi_nfit_ctl(), if call_pkg->nd_family is non-zero, while the lower 32 bits are zero. Furthermore, it is best to return EINVAL immediately upon seeing the invalid user input. The WARNING is insufficient to prevent further undefined behavior based on other invalid user input. All checks of the input value should be applied to the original variable call_pkg->nd_family. [iweiny: update commit message] Fixes: 6450ddb ("ACPI: NFIT: Define runtime firmware activation commands") Cc: stable@vger.kernel.org Reported-by: syzbot+c80d8dc0d9fa81a3cd8c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=c80d8dc0d9fa81a3cd8c Signed-off-by: Murad Masimov <m.masimov@mt-integration.ru> Link: https://patch.msgid.link/20250123163945.251-1-m.masimov@mt-integration.ru Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
1 parent d657fea commit de436a7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/acpi/nfit/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm,
485485
cmd_mask = nd_desc->cmd_mask;
486486
if (cmd == ND_CMD_CALL && call_pkg->nd_family) {
487487
family = call_pkg->nd_family;
488-
if (family > NVDIMM_BUS_FAMILY_MAX ||
488+
if (call_pkg->nd_family > NVDIMM_BUS_FAMILY_MAX ||
489489
!test_bit(family, &nd_desc->bus_family_mask))
490490
return -EINVAL;
491491
family = array_index_nospec(family,

0 commit comments

Comments
 (0)