Skip to content

Commit c13f073

Browse files
Mikulas Patockagregkh
authored andcommitted
dm ioctl: fix out of bounds array access when no devices
commit 4edbe1d upstream. 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]> [iwamatsu: Adjust context] Signed-off-by: Nobuhiro Iwamatsu <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2da1122 commit c13f073

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
@@ -524,7 +524,7 @@ static int list_devices(struct dm_ioctl *param, size_t param_size)
524524
* Grab our output buffer.
525525
*/
526526
nl = get_result_buffer(param, param_size, &len);
527-
if (len < needed) {
527+
if (len < needed || len < sizeof(nl->dev)) {
528528
param->flags |= DM_BUFFER_FULL_FLAG;
529529
goto out;
530530
}

0 commit comments

Comments
 (0)