Skip to content

Commit 4edbe1d

Browse files
Mikulas Patockasnitm
authored andcommitted
dm ioctl: fix out of bounds array access when no devices
If there are not any dm devices, we need to zero the "dev" argument in the first structure dm_name_list. However, this can cause out of bounds write, because the "needed" variable is zero and len may be less than eight. Fix this bug by reporting DM_BUFFER_FULL_FLAG if the result buffer is too small to hold the "nl->dev" value. Signed-off-by: Mikulas Patocka <[email protected]> Reported-by: Dan Carpenter <[email protected]> Cc: [email protected] Signed-off-by: Mike Snitzer <[email protected]>
1 parent 5424a0b commit 4edbe1d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/dm-ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static int list_devices(struct file *filp, struct dm_ioctl *param, size_t param_
529529
* Grab our output buffer.
530530
*/
531531
nl = orig_nl = get_result_buffer(param, param_size, &len);
532-
if (len < needed) {
532+
if (len < needed || len < sizeof(nl->dev)) {
533533
param->flags |= DM_BUFFER_FULL_FLAG;
534534
goto out;
535535
}

0 commit comments

Comments
 (0)