]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
btrfs: relocation: set trans to be NULL after ending transaction
authorPan Bian <bianpan2016@163.com>
Fri, 23 Nov 2018 10:10:15 +0000 (18:10 +0800)
committerSultan Alsawaf <sultan.alsawaf@canonical.com>
Wed, 24 Jul 2019 15:44:57 +0000 (09:44 -0600)
commit0b5dcae87066761bf3e79e39aa73e5adbdb48663
tree0174f53f79b8e4759d1beed34e964782cde38c48
parentc32da171ca838217cec70f44c6a12665160519ad
btrfs: relocation: set trans to be NULL after ending transaction

BugLink: https://bugs.launchpad.net/bugs/1836968
commit 42a657f57628402c73237547f0134e083e2f6764 upstream.

The function relocate_block_group calls btrfs_end_transaction to release
trans when update_backref_cache returns 1, and then continues the loop
body. If btrfs_block_rsv_refill fails this time, it will jump out the
loop and the freed trans will be accessed. This may result in a
use-after-free bug. The patch assigns NULL to trans after trans is
released so that it will not be accessed.

Fixes: 0647bf564f1 ("Btrfs: improve forever loop when doing balance relocation")
CC: stable@vger.kernel.org # 4.4+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Pan Bian <bianpan2016@163.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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/btrfs/relocation.c