Skip to content

Commit 046667c

Browse files
author
Al Viro
committed
memcg_write_event_control(): fix a user-triggerable oops
we are *not* guaranteed that anything past the terminating NUL is mapped (let alone initialized with anything sane). Fixes: 0dea116 ("cgroup: implement eventfd-based generic API for notifications") Cc: [email protected] Cc: Andrew Morton <[email protected]> Acked-by: Michal Hocko <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 9a2fa14 commit 046667c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mm/memcontrol-v1.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,9 +1842,12 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of,
18421842
buf = endp + 1;
18431843

18441844
cfd = simple_strtoul(buf, &endp, 10);
1845-
if ((*endp != ' ') && (*endp != '\0'))
1845+
if (*endp == '\0')
1846+
buf = endp;
1847+
else if (*endp == ' ')
1848+
buf = endp + 1;
1849+
else
18461850
return -EINVAL;
1847-
buf = endp + 1;
18481851

18491852
event = kzalloc(sizeof(*event), GFP_KERNEL);
18501853
if (!event)

0 commit comments

Comments
 (0)