libnvdimm: Out of bounds read in __nd_ioctl()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 25 Feb 2020 16:20:56 +0000 (19:20 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 05:59:14 +0000 (07:59 +0200)
commit2567276be7417e15f6b5b3720575e865a16a01d0
treee3a2b3e0859777c7c0b5ca5d0b611320cbe3fbee
parent24b731dca3005d3bbea7466b5bc7e3454e94e163
libnvdimm: Out of bounds read in __nd_ioctl()

[ Upstream commit f84afbdd3a9e5e10633695677b95422572f920dc ]

The "cmd" comes from the user and it can be up to 255.  It it's more
than the number of bits in long, it results out of bounds read when we
check test_bit(cmd, &cmd_mask).  The highest valid value for "cmd" is
ND_CMD_CALL (10) so I added a compare against that.

Fixes: 62232e45f4a2 ("libnvdimm: control (ioctl) messages for nvdimm_bus and nvdimm devices")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200225162055.amtosfy7m35aivxg@kili.mountain
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvdimm/bus.c