summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYou-Kai Zheng <ykzheng@synology.com>2026-06-16 18:39:07 +0800
committerDavid Sterba <dsterba@suse.com>2026-07-14 07:02:39 +0200
commitb95181f3929ff98949fa9460ca93eccebbf2d7fc (patch)
tree29d68b90eaf780ad683aad7ff4c0e0aef4819fad
parentb78fe9563e2d5ae47805f1e5dc722c91fd30e1f8 (diff)
downloadlinux-next-b95181f3929ff98949fa9460ca93eccebbf2d7fc.tar.gz
linux-next-b95181f3929ff98949fa9460ca93eccebbf2d7fc.zip
btrfs: declare btrfs_ioctl_search_args_v2::buf as __u8
The variable-sized buffer buf in struct btrfs_ioctl_search_args_v2 is declared as __u64[], but it holds a packed byte stream of search results, where all offsets into the buffer are in bytes. Declaring buf as __u64[] makes it easy for user space to write incorrect pointer arithmetic: adding a byte offset directly to a __u64 pointer scales the offset by 8, landing at byte position offset*8 instead of offset. This recently caused an infinite loop in btrfs-progs: the accessor read all-zero data from misaddressed items, which fed zeroed search keys back into the ioctl loop and spun forever. The issue was worked around at the time by disabling TREE_SEARCH_V2 entirely in btrfs-progs (d73e69824854: "btrfs-progs: temporarily disable usage of v2 of search tree ioctl"). The kernel side already treats buf as a byte buffer, so change the declaration to __u8[] to match the actual semantics and prevent similar misuse in user space. The change is ABI compatible: both the structure size and alignment are unchanged. Fixes: cc68a8a5a433 ("btrfs: new ioctl TREE_SEARCH_V2") Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: You-Kai Zheng <ykzheng@synology.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--include/uapi/linux/btrfs.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index 9b576603b3f1..0a13baf3d8d1 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -598,7 +598,7 @@ struct btrfs_ioctl_search_args_v2 {
__u64 buf_size; /* in - size of buffer
* out - on EOVERFLOW: needed size
* to store item */
- __u64 buf[]; /* out - found items */
+ __u8 buf[]; /* out - found items */
};
/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */