]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: use u64 for buffer sizes in the tree search ioctls
authorFilipe Manana <fdmanana@suse.com>
Fri, 13 Oct 2023 09:05:48 +0000 (10:05 +0100)
committerDavid Sterba <dsterba@suse.com>
Fri, 3 Nov 2023 15:38:45 +0000 (16:38 +0100)
commitdec96fc2dcb59723e041416b8dc53e011b4bfc2e
tree48db1d2bdb5d8796357c088c928c8e96e4cd3618
parentc6e8f898f56fae2cb5bc4396bec480f23cd8b066
btrfs: use u64 for buffer sizes in the tree search ioctls

In the tree search v2 ioctl we use the type size_t, which is an unsigned
long, to track the buffer size in the local variable 'buf_size'. An
unsigned long is 32 bits wide on a 32 bits architecture. The buffer size
defined in struct btrfs_ioctl_search_args_v2 is a u64, so when we later
try to copy the local variable 'buf_size' to the argument struct, when
the search returns -EOVERFLOW, we copy only 32 bits which will be a
problem on big endian systems.

Fix this by using a u64 type for the buffer sizes, not only at
btrfs_ioctl_tree_search_v2(), but also everywhere down the call chain
so that we can use the u64 at btrfs_ioctl_tree_search_v2().

Fixes: cc68a8a5a433 ("btrfs: new ioctl TREE_SEARCH_V2")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/linux-btrfs/ce6f4bd6-9453-4ffe-ba00-cee35495e10f@moroto.mountain/
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ioctl.c