Blob Blame History Raw
From 92b66d2cdd7a4f6f6aa31be5f16a3f0c88902690 Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <mszeredi@redhat.com>
Date: Fri, 6 Jul 2018 23:57:02 +0200
Subject: [PATCH] vfs: limit size of dedupe
Git-commit: 92b66d2cdd7a4f6f6aa31be5f16a3f0c88902690
Patch-mainline: v4.19-rc1
References: bsc#1132397, bsc#1132219

Suggested-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>

---
 fs/read_write.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index 153f8f690490..f43bb12b4759 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2003,6 +2003,9 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 	if (off + len > i_size_read(src))
 		return -EINVAL;
 
+	/* Arbitrary 1G limit on a single dedupe request, can be raised. */
+	len = min_t(u64, len, 1 << 30);
+
 	/* pre-format output fields to sane values */
 	for (i = 0; i < count; i++) {
 		same->info[i].bytes_deduped = 0ULL;
-- 
2.16.4