Skip to content
  • Jiufei Xue's avatar
    blk-throttle: fix null pointer dereference while throttling writeback IOs · 53cfdc10
    Jiufei Xue authored
    
    
    A null pointer dereference can occur when blkcg is removed manually
    with writeback IOs inflight. This is caused by the following case:
    
    Writeback kworker submit the bio and set bio->bi_cg_private to tg
    in blk_throtl_assoc_bio.
    Then we remove the block cgroup manually, the blkg and tg would be
    freed if there is no request inflight.
    When the submitted bio come back, blk_throtl_bio_endio() fetch the tg
    which was already freed.
    
    Fix this by increasing the refcount of blkg in funcion
    blk_throtl_assoc_bio() so that the blkg will not be freed until the
    bio_endio called.
    
    Reviewed-by: default avatarShaohua Li <shli@fb.com>
    Signed-off-by: default avatarJiufei Xue <jiufei.xjf@alibaba-inc.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    53cfdc10