lkml.org 
[lkml]   [2021]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 43/71] dm snapshot: fix crash with transient storage and zero chunk size
    Date
    From: Mikulas Patocka <mpatocka@redhat.com>

    commit c699a0db2d62e3bbb7f0bf35c87edbc8d23e3062 upstream.

    The following commands will crash the kernel:

    modprobe brd rd_size=1048576
    dmsetup create o --table "0 `blockdev --getsize /dev/ram0` snapshot-origin /dev/ram0"
    dmsetup create s --table "0 `blockdev --getsize /dev/ram0` snapshot /dev/ram0 /dev/ram1 N 0"

    The reason is that when we test for zero chunk size, we jump to the label
    bad_read_metadata without setting the "r" variable. The function
    snapshot_ctr destroys all the structures and then exits with "r == 0". The
    kernel then crashes because it falsely believes that snapshot_ctr
    succeeded.

    In order to fix the bug, we set the variable "r" to -EINVAL.

    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/md/dm-snap.c | 1 +
    1 file changed, 1 insertion(+)

    --- a/drivers/md/dm-snap.c
    +++ b/drivers/md/dm-snap.c
    @@ -1407,6 +1407,7 @@ static int snapshot_ctr(struct dm_target

    if (!s->store->chunk_size) {
    ti->error = "Chunk size not set";
    + r = -EINVAL;
    goto bad_read_metadata;
    }


    \
     
     \ /
      Last update: 2021-05-24 17:55    [W:4.084 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site