]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: send: limit number of clones and allocated memory size
authorDavid Sterba <dsterba@suse.com>
Tue, 24 Jan 2023 19:32:10 +0000 (20:32 +0100)
committerDavid Sterba <dsterba@suse.com>
Fri, 27 Jan 2023 13:57:05 +0000 (14:57 +0100)
commit33e17b3f5ab74af12aca58c515bc8424ff69a343
tree90cbfd5d60eeabb66ea37bbc9ccb10e5eae62846
parenteadd7deca0ad8a83edb2b894d8326c78e78635d6
btrfs: send: limit number of clones and allocated memory size

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: syzbot+4376a9a073770c173269@syzkaller.appspotmail.com
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/send.c