summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin/git@git.tavy.me:linux.git
diff options
context:
space:
mode:
authorLeo Martins <loemra.dev@gmail.com>2025-12-12 17:26:26 -0800
committerDavid Sterba <dsterba@suse.com>2025-12-16 22:53:15 +0100
commit83f59076a1ae6f5c6845d6f7ed3a1a373d883684 (patch)
treec23cee9753687246faa7efd0f380c0aeeeca532f /tools/perf/scripts/python/bin/git@git.tavy.me:linux.git
parent7ba0b6461bc4edb3005ea6e00cdae189bcf908a5 (diff)
btrfs: fix use-after-free warning in btrfs_get_or_create_delayed_node()
Previously, btrfs_get_or_create_delayed_node() set the delayed_node's refcount before acquiring the root->delayed_nodes lock. Commit e8513c012de7 ("btrfs: implement ref_tracker for delayed_nodes") moved refcount_set inside the critical section, which means there is no longer a memory barrier between setting the refcount and setting btrfs_inode->delayed_node. Without that barrier, the stores to node->refs and btrfs_inode->delayed_node may become visible out of order. Another thread can then read btrfs_inode->delayed_node and attempt to increment a refcount that hasn't been set yet, leading to a refcounting bug and a use-after-free warning. The fix is to move refcount_set back to where it was to take advantage of the implicit memory barrier provided by lock acquisition. Because the allocations now happen outside of the lock's critical section, they can use GFP_NOFS instead of GFP_ATOMIC. Reported-by: kernel test robot <oliver.sang@intel.com> Closes: https://lore.kernel.org/oe-lkp/202511262228.6dda231e-lkp@intel.com Fixes: e8513c012de7 ("btrfs: implement ref_tracker for delayed_nodes") Tested-by: kernel test robot <oliver.sang@intel.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Leo Martins <loemra.dev@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/bin/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions