Skip to contentSkip to conversation

fanotify: don't write with zero size

PATCH Superseded Fabian Frederick 2 participants 2 messages May 11, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 7/9 fanotify: don't write with zero size

check count in fanotify_write() and return -EINVAL when 0

---
 fs/notify/fanotify/fanotify_user.c | 3 +++
 1 file changed, 3 insertions(+)
fs/notify/fanotify/fanotify_user.c +3 -0
index 02a314acc757..6e19dacb2475 100644
@@ -485,6 +485,9 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
 	if (!IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS))
 		return -EINVAL;
 
+	if (!count)
+		return -EINVAL;
+
 	group = file->private_data;
 
 	if (count > sizeof(response))
Signature · 1 line
2.26.2
#1 lore raw
Quoted 13 lines · Fabian Frederick

check count in fanotify_write() and return -EINVAL when 0

---
 fs/notify/fanotify/fanotify_user.c | 3 +++
 1 file changed, 3 insertions(+)
fs/notify/fanotify/fanotify_user.c +0 -0
index 02a314acc757..6e19dacb2475 100644

fs/notify/fanotify/fanotify_user.c static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t · line 490

Quoted 6 lines
fs/notify/fanotify/fanotify_user.c +3 -0
@@ -485,6 +485,9 @@ static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t
        if (!IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS))
                return -EINVAL;
 
+       if (!count)
+               return -EINVAL;
+

Maybe even (count < sizeof(response)) ?

Quoted 6 lines
fs/notify/fanotify/fanotify_user.c +0 -1
        group = file->private_data;
 
        if (count > sizeof(response))
--

2.26.2