Bug 7608 - btrfs: use u64 for buffer sizes in the tree search ioctls
Summary: btrfs: use u64 for buffer sizes in the tree search ioctls
Status: RESOLVED FIXED
Alias: None
Product: ANCK 5.10 Dev
Classification: ANCK
Component: fs (show other bugs) fs
Version: unspecified
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: zhujun
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-22 14:49 UTC by zhujun
Modified: 2023-11-22 16:17 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhujun cmss_group 2023-11-22 14:49:08 UTC
kernel-5.10 软件逻辑bug

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().



Additional info:

社区有patch已经解决
btrfs: use u64 for buffer sizes in the tree search ioctls

commit 4be0407ffcf6db5bf520aac6e950e9488c96456b

Reference:https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.10.y&id=4be0407ffcf6db5bf520aac6e950e9488c96456b

git cherry-pick -s 4be0407ffc(with stable-v5.10.201 repo added)
Comment 1 小龙 admin 2023-11-22 15:24:21 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/2447
Comment 2 Joseph Qi alibaba_cloud_group 2023-11-22 16:17:03 UTC
(In reply to 小龙 from comment #1)
> The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/2447

merged