• Ilya Dryomov's avatar
    rbd: retrieve and check lock owner twice before blocklisting · 58815900
    Ilya Dryomov authored
    An attempt to acquire exclusive lock can race with the current lock
    owner closing the image:
    
    1. lock is held by client123, rbd_lock() returns -EBUSY
    2. get_lock_owner_info() returns client123 instance details
    3. client123 closes the image, lock is released
    4. find_watcher() returns 0 as there is no matching watcher anymore
    5. client123 instance gets erroneously blocklisted
    
    Particularly impacted is mirror snapshot scheduler in snapshot-based
    mirroring since it happens to open and close images a lot (images are
    opened only for as long as it takes to take the next mirror snapshot,
    the same client instance is used for all images).
    
    To reduce the potential for erroneous blocklisting, retrieve the lock
    owner again after find_watcher() returns 0.  If it's still there, make
    sure it matches the previously detected lock owner.
    
    Cc: stable@vger.kernel.org # f38cb9d9: rbd: make get_lock_owner_info() return a single locker or NULL
    Cc: stable@vger.kernel.org # 8ff2c64c: rbd: harden get_lock_owner_info() a bit
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    Reviewed-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
    58815900
rbd.c 185 KB