Skip to content

Commit 6d91d57

Browse files
Dan Carpentercasparant
authored andcommitted
libnvdimm: Out of bounds read in __nd_ioctl()
fix #29902604 commit f84afbd upstream 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 <dan.carpenter@oracle.com> Reviewed-by: Artie Ding <artie.ding@linux.alibaba.com>
1 parent b2250b4 commit 6d91d57

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
@@ -1005,8 +1005,10 @@ static int __nd_ioctl(struct nvdimm_bus *nvdimm_bus, struct nvdimm *nvdimm,
10051005
return -EFAULT;
10061006
}
10071007

1008-
if (!desc || (desc->out_num + desc->in_num == 0) ||
1009-
!test_bit(cmd, &cmd_mask))
1008+
if (!desc ||
1009+
(desc->out_num + desc->in_num == 0) ||
1010+
cmd > ND_CMD_CALL ||
1011+
!test_bit(cmd, &cmd_mask))
10101012
return -ENOTTY;
10111013

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

0 commit comments

Comments
 (0)