• DingXiang's avatar
    dm snapshot: disallow the COW and origin devices from being identical · e9a0e1c3
    DingXiang authored
    commit 4df2bf46 upstream.
    
    Otherwise loading a "snapshot" table using the same device for the
    origin and COW devices, e.g.:
    
    echo "0 20971520 snapshot 253:3 253:3 P 8" | dmsetup create snap
    
    will trigger:
    
    BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
    [ 1958.979934] IP: [<ffffffffa040efba>] dm_exception_store_set_chunk_size+0x7a/0x110 [dm_snapshot]
    [ 1958.989655] PGD 0
    [ 1958.991903] Oops: 0000 [#1] SMP
    ...
    [ 1959.059647] CPU: 9 PID: 3556 Comm: dmsetup Tainted: G          IO    4.5.0-rc5.snitm+ #150
    ...
    [ 1959.083517] task: ffff8800b9660c80 ti: ffff88032a954000 task.ti: ffff88032a954000
    [ 1959.091865] RIP: 0010:[<ffffffffa040efba>]  [<ffffffffa040efba>] dm_exception_store_set_chunk_size+0x7a/0x110 [dm_snapshot]
    [ 1959.104295] RSP: 0018:ffff88032a957b30  EFLAGS: 00010246
    [ 1959.110219] RAX: 0000000000000000 RBX: 0000000000000008 RCX: 0000000000000001
    [ 1959.118180] RDX: 00000000...
    e9a0e1c3
dm-snap.c 56.9 KB