Skip to contentSkip to conversation

fanotify: don't write with size under sizeof(response)

PATCH In review Fabian Frederick 1 participant 1 message May 12, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 6/6 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.

---
V2: don't write with size under sizeof(response), not only 0

 fs/notify/fanotify/fanotify_user.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
fs/notify/fanotify/fanotify_user.c +4 -2
index 02a314acc757..63b5dffdca9e 100644
@@ -487,8 +487,10 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
 
 	group = file->private_data;
 
-	if (count > sizeof(response))
-		count = sizeof(response);
+	if (count < sizeof(response))
+		return -EINVAL;
+
+	count = sizeof(response);
 
 	pr_debug("%s: group=%p count=%zu\n", __func__, group, count);
 
Signature · 1 line
2.26.2