* [PATCH] btrfs: ref-verify: free ref cache before clearing mount opt
@ 2024-01-03 10:31 Fedor Pchelkin
2024-01-04 3:41 ` Anand Jain
2024-01-04 16:00 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Fedor Pchelkin @ 2024-01-03 10:31 UTC (permalink / raw)
To: Josef Bacik
Cc: Fedor Pchelkin, David Sterba, Chris Mason, linux-btrfs,
linux-kernel, Alexey Khoroshilov, lvc-project,
syzbot+be14ed7728594dc8bd42, syzbot+c563a3c79927971f950f
As clearing REF_VERIFY mount option indicates there were some errors in a
ref-verify process, a ref cache is not relevant anymore and should be
freed.
btrfs_free_ref_cache() requires REF_VERIFY option being set so call
it just before clearing the mount option.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Fixes: fd708b81d972 ("Btrfs: add a extent ref verify tool")
Reported-by: syzbot+be14ed7728594dc8bd42@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/lkml/000000000000e5a65c05ee832054@google.com/
Reported-by: syzbot+c563a3c79927971f950f@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/lkml/0000000000007fe09705fdc6086c@google.com/
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
fs/btrfs/ref-verify.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
index 6486f0d7e993..8c4fc98ca9ce 100644
--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -889,8 +889,10 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
out_unlock:
spin_unlock(&fs_info->ref_verify_lock);
out:
- if (ret)
+ if (ret) {
+ btrfs_free_ref_cache(fs_info);
btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
+ }
return ret;
}
@@ -1021,8 +1023,8 @@ int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
}
}
if (ret) {
- btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
btrfs_free_ref_cache(fs_info);
+ btrfs_clear_opt(fs_info->mount_opt, REF_VERIFY);
}
btrfs_free_path(path);
return ret;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: ref-verify: free ref cache before clearing mount opt
2024-01-03 10:31 [PATCH] btrfs: ref-verify: free ref cache before clearing mount opt Fedor Pchelkin
@ 2024-01-04 3:41 ` Anand Jain
2024-01-04 16:00 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2024-01-04 3:41 UTC (permalink / raw)
To: Fedor Pchelkin, Josef Bacik
Cc: David Sterba, Chris Mason, linux-btrfs, linux-kernel,
Alexey Khoroshilov, lvc-project, syzbot+be14ed7728594dc8bd42,
syzbot+c563a3c79927971f950f
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Thx, Anand
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: ref-verify: free ref cache before clearing mount opt
2024-01-03 10:31 [PATCH] btrfs: ref-verify: free ref cache before clearing mount opt Fedor Pchelkin
2024-01-04 3:41 ` Anand Jain
@ 2024-01-04 16:00 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2024-01-04 16:00 UTC (permalink / raw)
To: Fedor Pchelkin
Cc: Josef Bacik, David Sterba, Chris Mason, linux-btrfs,
linux-kernel, Alexey Khoroshilov, lvc-project,
syzbot+be14ed7728594dc8bd42, syzbot+c563a3c79927971f950f
On Wed, Jan 03, 2024 at 01:31:27PM +0300, Fedor Pchelkin wrote:
> As clearing REF_VERIFY mount option indicates there were some errors in a
> ref-verify process, a ref cache is not relevant anymore and should be
> freed.
>
> btrfs_free_ref_cache() requires REF_VERIFY option being set so call
> it just before clearing the mount option.
>
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
>
> Fixes: fd708b81d972 ("Btrfs: add a extent ref verify tool")
> Reported-by: syzbot+be14ed7728594dc8bd42@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/lkml/000000000000e5a65c05ee832054@google.com/
> Reported-by: syzbot+c563a3c79927971f950f@syzkaller.appspotmail.com
> Closes: https://lore.kernel.org/lkml/0000000000007fe09705fdc6086c@google.com/
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-04 16:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03 10:31 [PATCH] btrfs: ref-verify: free ref cache before clearing mount opt Fedor Pchelkin
2024-01-04 3:41 ` Anand Jain
2024-01-04 16:00 ` David Sterba
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®