diff options
| author | Yochai Eisenrich <yochaie@sweet.security> | 2026-03-22 08:39:35 +0200 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-04-07 18:56:05 +0200 |
| commit | 973e57c726c1f8e77259d1c8e519519f1e9aea77 (patch) | |
| tree | 325ac2697d7bf8984639cd263189db328f0d2a1a /tools/perf/scripts/python/stackcollapse.py | |
| parent | cee4cfd6cc32a272a438836113cb698e2bca452c (diff) | |
btrfs: fix btrfs_ioctl_space_info() slot_count TOCTOU which can lead to info-leak
btrfs_ioctl_space_info() has a TOCTOU race between two passes over the
block group RAID type lists. The first pass counts entries to determine
the allocation size, then the second pass fills the buffer. The
groups_sem rwlock is released between passes, allowing concurrent block
group removal to reduce the entry count.
When the second pass fills fewer entries than the first pass counted,
copy_to_user() copies the full alloc_size bytes including trailing
uninitialized kmalloc bytes to userspace.
Fix by copying only total_spaces entries (the actually-filled count from
the second pass) instead of alloc_size bytes, and switch to kzalloc so
any future copy size mismatch cannot leak heap data.
Fixes: 7fde62bffb57 ("Btrfs: buffer results in the space_info ioctl")
CC: stable@vger.kernel.org # 3.0
Signed-off-by: Yochai Eisenrich <echelonh@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
