| To: | david@xxxxxxxxxxxxx, viro@xxxxxxxxxxxxxxxxxx, darrick.wong@xxxxxxxxxx |
|---|---|
| Subject: | [PATCH 2/6] vfs: cap dedupe request structure size at PAGE_SIZE |
| From: | "Darrick J. Wong" <darrick.wong@xxxxxxxxxx> |
| Date: | Thu, 25 Aug 2016 16:30:54 -0700 |
| Cc: | linux-xfs@xxxxxxxxxxxxxxx, "Kirill A. Shutemov" <kirill@xxxxxxxxxxxxx>, linux-fsdevel@xxxxxxxxxxxxxxx, linux-api@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx |
| Delivered-to: | xfs@xxxxxxxxxxx |
| In-reply-to: | <147216784041.525.7722906502172299465.stgit@xxxxxxxxxxxxxxxx> |
| References: | <147216784041.525.7722906502172299465.stgit@xxxxxxxxxxxxxxxx> |
| User-agent: | StGit/0.17.1-dirty |
Kirill A. Shutemov reports that the kernel doesn't try to cap dest_count
in any way, and uses the number to allocate kernel memory. This causes
high order allocation warnings in the kernel log if someone passes in a
big enough value. We should clamp the allocation at PAGE_SIZE to avoid
stressing the VM.
The two existing users of the dedupe ioctl never send more than 120
requests, so we can safely clamp dest_range at PAGE_SIZE, because with
4k pages we can handle up to 127 dedupe candidates. Given the max
extent length of 16MB, we can end up doing 2GB of IO which is plenty.
Reported-by: "Kirill A. Shutemov" <kirill@xxxxxxxxxxxxx>
Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
---
fs/ioctl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 26aba09..c415668 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -582,6 +582,10 @@ static int ioctl_file_dedupe_range(struct file *file, void
__user *arg)
}
size = offsetof(struct file_dedupe_range __user, info[count]);
+ if (size > PAGE_SIZE) {
+ ret = -ENOMEM;
+ goto out;
+ }
same = memdup_user(argp, size);
if (IS_ERR(same)) {
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH 1/6] vfs: fix return type of ioctl_file_dedupe_range, Darrick J. Wong |
|---|---|
| Next by Date: | [PATCH 3/6] vfs: support FS_XFLAG_REFLINK and FS_XFLAG_COWEXTSIZE, Darrick J. Wong |
| Previous by Thread: | [PATCH 1/6] vfs: fix return type of ioctl_file_dedupe_range, Darrick J. Wong |
| Next by Thread: | [PATCH 3/6] vfs: support FS_XFLAG_REFLINK and FS_XFLAG_COWEXTSIZE, Darrick J. Wong |
| Indexes: | [Date] [Thread] [Top] [All Lists] |