Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: zoned: fix missing RCU locking in error message when loading zone info

At btrfs_load_zone_info() we have an error path that is dereferencing
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")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Filipe Manana and committed by
David Sterba
fe4cd7ed 6ef8fbce

+1 -1
+1 -1
fs/btrfs/zoned.c
··· 1340 1340 switch (zone.cond) { 1341 1341 case BLK_ZONE_COND_OFFLINE: 1342 1342 case BLK_ZONE_COND_READONLY: 1343 - btrfs_err(fs_info, 1343 + btrfs_err_in_rcu(fs_info, 1344 1344 "zoned: offline/readonly zone %llu on device %s (devid %llu)", 1345 1345 (info->physical >> device->zone_info->zone_size_shift), 1346 1346 rcu_str_deref(device->name), device->devid);