Commit 70cd34dc authored by David Sterba's avatar David Sterba Committed by zhaoxiaoqiang11
Browse files

btrfs: send: limit number of clones and allocated memory size

stable inclusion
from stable-v5.10.171
commit 6195cea4c738146f6665f71944325766daef1a5f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7V9QX

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6195cea4c738146f6665f71944325766daef1a5f



----------------------------------------------------

[ Upstream commit 33e17b3f ]

The arg->clone_sources_count is u64 and can trigger a warning when a
huge value is passed from user space and a huge array is allocated.
Limit the allocated memory to 8MiB (can be increased if needed), which
in turn limits the number of clone sources to 8M / sizeof(struct
clone_root) = 8M / 40 = 209715.  Real world number of clones is from
tens to hundreds, so this is future proof.

Reported-by: default avatar <syzbot+4376a9a073770c173269@syzkaller.appspotmail.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
parent c6e9f80a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment