[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_D3FEC641C9842EEB2EE2CC8E67DB86DD9206@qq.com>
Date: Tue, 15 Oct 2024 17:55:58 +0800
From: Edward Adam Davis <eadavis@...com>
To: syzbot+c3a3a153f0190dca5be9@...kaller.appspotmail.com
Cc: linux-kernel@...r.kernel.org,
syzkaller-bugs@...glegroups.com
Subject: Re: [btrfs?] KASAN: slab-use-after-free Read in add_delayed_ref
using delayed_refs->lock to sync btrfs_work_helper and add_delayed_ref
#syz test
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 13c2e00d1270..cb57e65c9872 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -1058,7 +1058,6 @@ static int add_delayed_ref(struct btrfs_trans_handle *trans,
head_ref = new_head_ref;
merged = insert_delayed_ref(trans, head_ref, node);
- spin_unlock(&delayed_refs->lock);
/*
* Need to update the delayed_refs_rsv with any changes we may have
@@ -1073,8 +1072,12 @@ static int add_delayed_ref(struct btrfs_trans_handle *trans,
if (merged)
kmem_cache_free(btrfs_delayed_ref_node_cachep, node);
- if (qrecord_inserted)
- return btrfs_qgroup_trace_extent_post(trans, record, head_ref->bytenr);
+ if (qrecord_inserted) {
+ ret = btrfs_qgroup_trace_extent_post(trans, record, head_ref->bytenr);
+ spin_unlock(&delayed_refs->lock);
+ return ret;
+ }
+ spin_unlock(&delayed_refs->lock);
return 0;
free_record:
Powered by blists - more mailing lists