lkml.org 
[lkml]   [2019]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.0 096/238] btrfs: init csum_list before possible free
    Date
    5.0-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Dan Robertson <dan@dlrobertson.com>

    commit e49be14b8d80e23bb7c53d78c21717a474ade76b upstream.

    The scrub_ctx csum_list member must be initialized before scrub_free_ctx
    is called. If the csum_list is not initialized beforehand, the
    list_empty call in scrub_free_csums will result in a null deref if the
    allocation fails in the for loop.

    Fixes: a2de733c78fa ("btrfs: scrub")
    CC: stable@vger.kernel.org # 3.0+
    Reviewed-by: Nikolay Borisov <nborisov@suse.com>
    Signed-off-by: Dan Robertson <dan@dlrobertson.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    fs/btrfs/scrub.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/fs/btrfs/scrub.c
    +++ b/fs/btrfs/scrub.c
    @@ -584,6 +584,7 @@ static noinline_for_stack struct scrub_c
    sctx->pages_per_rd_bio = SCRUB_PAGES_PER_RD_BIO;
    sctx->curr = -1;
    sctx->fs_info = fs_info;
    + INIT_LIST_HEAD(&sctx->csum_list);
    for (i = 0; i < SCRUB_BIOS_PER_SCTX; ++i) {
    struct scrub_bio *sbio;

    @@ -608,7 +609,6 @@ static noinline_for_stack struct scrub_c
    atomic_set(&sctx->workers_pending, 0);
    atomic_set(&sctx->cancel_req, 0);
    sctx->csum_size = btrfs_super_csum_size(fs_info->super_copy);
    - INIT_LIST_HEAD(&sctx->csum_list);

    spin_lock_init(&sctx->list_lock);
    spin_lock_init(&sctx->stat_lock);

    \
     
     \ /
      Last update: 2019-03-22 13:31    [W:4.083 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site