Skip to content

Commit f84afbd

Browse files
Dan Carpenterdjbw
authored andcommitted
libnvdimm: Out of bounds read in __nd_ioctl()
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: 62232e4 ("libnvdimm: control (ioctl) messages for nvdimm_bus and nvdimm devices") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 01091c4 commit f84afbd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/nvdimm/bus.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
10421042
return -EFAULT;
10431043
}
10441044

1045-
if (!desc || (desc->out_num + desc->in_num == 0) ||
1046-
!test_bit(cmd, &cmd_mask))
1045+
if (!desc ||
1046+
(desc->out_num + desc->in_num == 0) ||
1047+
cmd > ND_CMD_CALL ||
1048+
!test_bit(cmd, &cmd_mask))
10471049
return -ENOTTY;
10481050

10491051
/* fail write commands (when read-only) */

0 commit comments

Comments
 (0)