hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/btrfs/send.c
....@@ -7276,10 +7276,10 @@
72767276 /*
72777277 * Check that we don't overflow at later allocations, we request
72787278 * clone_sources_count + 1 items, and compare to unsigned long inside
7279
- * access_ok.
7279
+ * access_ok. Also set an upper limit for allocation size so this can't
7280
+ * easily exhaust memory. Max number of clone sources is about 200K.
72807281 */
7281
- if (arg->clone_sources_count >
7282
- ULONG_MAX / sizeof(struct clone_root) - 1) {
7282
+ if (arg->clone_sources_count > SZ_8M / sizeof(struct clone_root)) {
72837283 ret = -EINVAL;
72847284 goto out;
72857285 }