Skip to content

Commit d4b0bcf

Browse files
committed
dlm: check the write size from user
Return EINVAL from write if the size is larger than allowed. Do this before allocating kernel memory for the bogus size, which could lead to OOM. Reported-by: Sasha Levin <levinsasha928@gmail.com> Tested-by: Jana Saout <jana@saout.de> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 6edacf0 commit d4b0bcf

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/dlm/user.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,11 @@ static ssize_t device_write(struct file *file, const char __user *buf,
503503
#endif
504504
return -EINVAL;
505505

506-
#ifdef CONFIG_COMPAT
507-
if (count > sizeof(struct dlm_write_request32) + DLM_RESNAME_MAXLEN)
508-
#else
506+
/*
507+
* can't compare against COMPAT/dlm_write_request32 because
508+
* we don't yet know if is64bit is zero
509+
*/
509510
if (count > sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN)
510-
#endif
511511
return -EINVAL;
512512

513513
kbuf = kzalloc(count + 1, GFP_NOFS);

0 commit comments

Comments
 (0)