Re: [PATCH v2] btrfs: don't access possibly stale fs_info data for printing duplicate device
From: David Sterba <hidden>
Date: 2020-11-16 15:40:56
From: David Sterba <hidden>
Date: 2020-11-16 15:40:56
On Mon, Nov 16, 2020 at 04:52:54PM +0900, Johannes Thumshirn wrote:
Syzbot reported a possible use-after-free when printing a duplicate device warning device_list_add(). At this point it can happen that a btrfs_device::fs_info is not correctly setup yet, so we're accessing stale data, when printing the warning message using the btrfs_printk() wrappers. Instead of printing possibly uninitialized or already freed memory in btrfs_printk(), explicitly pass in a NULL fs_info so the printing of the device name will be skipped altogether.
This would be good to add some info about the evolution of the fix, also a comment saying why we can't use fs_info.