• Mikulas Patocka's avatar
    dm ioctl: fix alignment of event number in the device list · 62e08243
    Mikulas Patocka authored
    The size of struct dm_name_list is different on 32-bit and 64-bit
    kernels (so "(nl + 1)" differs between 32-bit and 64-bit kernels).
    
    This mismatch caused some harmless difference in padding when using 32-bit
    or 64-bit kernel. Commit 23d70c5e ("dm ioctl: report event number in
    DM_LIST_DEVICES") added reporting event number in the output of
    DM_LIST_DEVICES_CMD. This difference in padding makes it impossible for
    userspace to determine the location of the event number (the location
    would be different when running on 32-bit and 64-bit kernels).
    
    Fix the padding by using offsetof(struct dm_name_list, name) instead of
    sizeof(struct dm_name_list) to determine the location of entries.
    
    Also, the ioctl version number is incremented to 37 so that userspace
    can use the version number to determine that the event number is present
    and correctly located.
    
    In addition, a global event is now raised when a DM device is created,
    removed, renamed or when table is swapped, so that the user can monitor
    for device changes.
    Reported-by: default avatarEugene Syromiatnikov <esyr@redhat.com>
    Fixes: 23d70c5e ("dm ioctl: report event number in DM_LIST_DEVICES")
    Cc: stable@vger.kernel.org # 4.13
    Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    62e08243
dm.c 68.1 KB