* [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info
@ 2024-10-02 14:15 fdmanana
2024-10-02 14:52 ` Johannes Thumshirn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: fdmanana @ 2024-10-02 14:15 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
At btrfs_load_zone_info() we have an error path that is dereferecing the
name of a device which is a RCU string but we are not holding a RCU read
lock, which is incorrect.
Fix this by using btrfs_err_in_rcu() instead of btrfs_err().
The problem is there since commit 08e11a3db098 ("btrfs: zoned: load zone's
allocation offset"), back then at btrfs_load_block_group_zone_info() but
then later on that code was factored out into the helper
btrfs_load_zone_info() by commit 09a46725cc84 ("btrfs: zoned: factor out
per-zone logic from btrfs_load_block_group_zone_info").
Fixes: 08e11a3db098 ("btrfs: zoned: load zone's allocation offset")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/zoned.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 00a016691d8e..dbcbf754d284 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1340,7 +1340,7 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
switch (zone.cond) {
case BLK_ZONE_COND_OFFLINE:
case BLK_ZONE_COND_READONLY:
- btrfs_err(fs_info,
+ btrfs_err_in_rcu(fs_info,
"zoned: offline/readonly zone %llu on device %s (devid %llu)",
(info->physical >> device->zone_info->zone_size_shift),
rcu_str_deref(device->name), device->devid);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info
2024-10-02 14:15 [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info fdmanana
@ 2024-10-02 14:52 ` Johannes Thumshirn
2024-10-02 21:13 ` Qu Wenruo
2024-10-03 1:38 ` Naohiro Aota
2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2024-10-02 14:52 UTC (permalink / raw)
To: fdmanana@kernel.org, linux-btrfs@vger.kernel.org
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info
2024-10-02 14:15 [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info fdmanana
2024-10-02 14:52 ` Johannes Thumshirn
@ 2024-10-02 21:13 ` Qu Wenruo
2024-10-03 1:38 ` Naohiro Aota
2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2024-10-02 21:13 UTC (permalink / raw)
To: fdmanana, linux-btrfs
在 2024/10/2 23:45, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> At btrfs_load_zone_info() we have an error path that is dereferecing the
> name of a device which is a RCU string but we are not holding a RCU read
> lock, which is incorrect.
>
> Fix this by using btrfs_err_in_rcu() instead of btrfs_err().
>
> The problem is there since commit 08e11a3db098 ("btrfs: zoned: load zone's
> allocation offset"), back then at btrfs_load_block_group_zone_info() but
> then later on that code was factored out into the helper
> btrfs_load_zone_info() by commit 09a46725cc84 ("btrfs: zoned: factor out
> per-zone logic from btrfs_load_block_group_zone_info").
>
> Fixes: 08e11a3db098 ("btrfs: zoned: load zone's allocation offset")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> fs/btrfs/zoned.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 00a016691d8e..dbcbf754d284 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -1340,7 +1340,7 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
> switch (zone.cond) {
> case BLK_ZONE_COND_OFFLINE:
> case BLK_ZONE_COND_READONLY:
> - btrfs_err(fs_info,
> + btrfs_err_in_rcu(fs_info,
> "zoned: offline/readonly zone %llu on device %s (devid %llu)",
> (info->physical >> device->zone_info->zone_size_shift),
> rcu_str_deref(device->name), device->devid);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info
2024-10-02 14:15 [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info fdmanana
2024-10-02 14:52 ` Johannes Thumshirn
2024-10-02 21:13 ` Qu Wenruo
@ 2024-10-03 1:38 ` Naohiro Aota
2 siblings, 0 replies; 4+ messages in thread
From: Naohiro Aota @ 2024-10-03 1:38 UTC (permalink / raw)
To: fdmanana@kernel.org; +Cc: linux-btrfs@vger.kernel.org
On Wed, Oct 02, 2024 at 03:15:07PM GMT, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> At btrfs_load_zone_info() we have an error path that is dereferecing the
> name of a device which is a RCU string but we are not holding a RCU read
> lock, which is incorrect.
>
> Fix this by using btrfs_err_in_rcu() instead of btrfs_err().
>
> The problem is there since commit 08e11a3db098 ("btrfs: zoned: load zone's
> allocation offset"), back then at btrfs_load_block_group_zone_info() but
> then later on that code was factored out into the helper
> btrfs_load_zone_info() by commit 09a46725cc84 ("btrfs: zoned: factor out
> per-zone logic from btrfs_load_block_group_zone_info").
>
> Fixes: 08e11a3db098 ("btrfs: zoned: load zone's allocation offset")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Thank you catching this.
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
> fs/btrfs/zoned.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 00a016691d8e..dbcbf754d284 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -1340,7 +1340,7 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
> switch (zone.cond) {
> case BLK_ZONE_COND_OFFLINE:
> case BLK_ZONE_COND_READONLY:
> - btrfs_err(fs_info,
> + btrfs_err_in_rcu(fs_info,
> "zoned: offline/readonly zone %llu on device %s (devid %llu)",
> (info->physical >> device->zone_info->zone_size_shift),
> rcu_str_deref(device->name), device->devid);
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-03 1:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02 14:15 [PATCH] btrfs: zoned: fix missing rcu locking in error message when loading zone info fdmanana
2024-10-02 14:52 ` Johannes Thumshirn
2024-10-02 21:13 ` Qu Wenruo
2024-10-03 1:38 ` Naohiro Aota
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox