FAILED: patch "[PATCH] btrfs: relocation: set trans to be NULL after ending" failed to apply to 4.4-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
42a657f57628402c73237547f0134e083e2f6764Mon Sep 17 00:00:00 2001
From: Pan Bian <[email protected]>
Date: Fri, 23 Nov 2018 18:10:15 +0800
Subject: [PATCH] btrfs: relocation: set trans to be NULL after ending
transaction
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.
fs/btrfs/relocation.c +1 -0
@@ -3959,6 +3959,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc) restart:if (update_backref_cache (trans, &rc->backref_cache)) {btrfs_end_transaction (trans); + trans =NULL ;continue ; }