• Xiubo Li's avatar
    ceph: correctly handle releasing an embedded cap flush · b2f9fa1f
    Xiubo Li authored
    The ceph_cap_flush structures are usually dynamically allocated, but
    the ceph_cap_snap has an embedded one.
    
    When force umounting, the client will try to remove all the session
    caps. During this, it will free them, but that should not be done
    with the ones embedded in a capsnap.
    
    Fix this by adding a new boolean that indicates that the cap flush is
    embedded in a capsnap, and skip freeing it if that's set.
    
    At the same time, switch to using list_del_init() when detaching the
    i_list and g_list heads.  It's possible for a forced umount to remove
    these objects but then handle_cap_flushsnap_ack() races in and does the
    list_del_init() again, corrupting memory.
    
    Cc: stable@vger.kernel.org
    URL: https://tracker.ceph.com/issues/52283Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
    Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    b2f9fa1f
snap.c 32 KB