Skip to content

Commit 5e23663

Browse files
Fabian Frederickjankara
authored andcommitted
fanotify: don't write with size under sizeof(response)
fanotify_write() only aligned copy_from_user size to sizeof(response) for higher values. This patch avoids all values below as suggested by Amir Goldstein and set to response size unconditionally. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Fabian Frederick <[email protected]> Reviewed-by: Amir Goldstein <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 5a44909 commit 5e23663

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,10 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
487487

488488
group = file->private_data;
489489

490-
if (count > sizeof(response))
491-
count = sizeof(response);
490+
if (count < sizeof(response))
491+
return -EINVAL;
492+
493+
count = sizeof(response);
492494

493495
pr_debug("%s: group=%p count=%zu\n", __func__, group, count);
494496

0 commit comments

Comments
 (0)