]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
acpi/nfit: improve bounds checking for 'func'
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 25 Feb 2020 16:20:06 +0000 (19:20 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Apr 2020 07:06:33 +0000 (09:06 +0200)
commita4c109ee2866ee1522e0daa0c9296ae7bb987455
treea7b39f9c3f49a611572fb25a0732b9a889f19e3d
parent7767b37c1a4c0af2b89f56403c9c48442f703d04
acpi/nfit: improve bounds checking for 'func'

commit 01091c496f920e634ea84b689f480c39016752a8 upstream.

The 'func' variable can come from the user in the __nd_ioctl().  If it's
too high then the (1 << func) shift in acpi_nfit_clear_to_send() is
undefined.  In acpi_nfit_ctl() we pass 'func' to test_bit(func, &dsm_mask)
which could result in an out of bounds access.

To fix these issues, I introduced the NVDIMM_CMD_MAX (31) define and
updated nfit_dsm_revid() to use that define as well instead of magic
numbers.

Fixes: 11189c1089da ("acpi/nfit: Fix command-supported detection")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/20200225161927.hvftuq7kjn547fyj@kili.mountain
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/acpi/nfit/core.c
drivers/acpi/nfit/nfit.h