From: Pei Li <peili.dev@gmail.com>
To: Kent Overstreet <kent.overstreet@linux.dev>,
Brian Foster <bfoster@redhat.com>
Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org,
skhan@linuxfoundation.org, syzkaller-bugs@googlegroups.com,
linux-kernel-mentees@lists.linuxfoundation.org,
syzbot+e74fea078710bbca6f4b@syzkaller.appspotmail.com,
Pei Li <peili.dev@gmail.com>
Subject: [PATCH] Fix WARNING: suspicious RCU usage in bch2_bucket_ref_update
Date: Wed, 10 Jul 2024 08:33:24 -0700 [thread overview]
Message-ID: <20240710-bug10-v1-1-f1f8cf98f7c0@gmail.com> (raw)
When dereference ca->bucket_gens, we are expecting one of the three
locks to be hold if ca->fs is not NULL.
This patch acquires mark_lock before entering __mark_pointer()
Note: testing is done by a robot and is best-effort only.
To: Kent Overstreet <kent.overstreet@linux.dev>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-bcachefs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org
Cc: syzkaller-bugs@googlegroups.com
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Reported-by: syzbot+e74fea078710bbca6f4b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=e74fea078710bbca6f4b
Tested-by: syzbot+e74fea078710bbca6f4b@syzkaller.appspotmail.com
Signed-off-by: Pei Li <peili.dev@gmail.com>
---
Syzbot reported the following warning:
fs/bcachefs/buckets.h:107 suspicious rcu_dereference_check() usage!
When dereference ca->bucket_gens, we are expecting one of the three
locks to be hold if ca->fs is not NULL.
This patch acquires mark_lock before entering __mark_pointer()
Tested on:
commit: 34afb82a Merge tag '6.10-rc6-smb3-server-fixes' of git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1492e87e980000
kernel config: https://syzkaller.appspot.com/x/.config?x=42a432cfd0e579e0
dashboard link: https://syzkaller.appspot.com/bug?extid=e74fea078710bbca6f4b
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=15e2e87e980000
Note: testing is done by a robot and is best-effort only.
---
fs/bcachefs/buckets.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index 743d57eba760..03147e46dc47 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -1033,8 +1033,14 @@ static int bch2_trigger_pointer(struct btree_trans *trans,
if (flags & BTREE_TRIGGER_transactional) {
struct bkey_i_alloc_v4 *a = bch2_trans_start_alloc_update(trans, bucket);
+
+ percpu_down_read(&c->mark_lock);
+
ret = PTR_ERR_OR_ZERO(a) ?:
__mark_pointer(trans, ca, k, &p.ptr, *sectors, bp.data_type, &a->v);
+
+ percpu_up_read(&c->mark_lock);
+
if (ret)
goto err;
---
base-commit: 256abd8e550ce977b728be79a74e1729438b4948
change-id: 20240709-bug10-6b354d193f20
Best regards,
--
Pei Li <peili.dev@gmail.com>
next reply other threads:[~2024-07-10 15:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 15:33 Pei Li [this message]
2024-07-10 16:45 ` Kent Overstreet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240710-bug10-v1-1-f1f8cf98f7c0@gmail.com \
--to=peili.dev@gmail.com \
--cc=bfoster@redhat.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+e74fea078710bbca6f4b@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®