]> www.infradead.org Git - users/hch/xfs.git/commitdiff
mm: huge_memory: handle strsep not finding delimiter
authorLeo Stone <leocstone@gmail.com>
Mon, 16 Dec 2024 04:27:51 +0000 (20:27 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 19 Dec 2024 03:04:47 +0000 (19:04 -0800)
split_huge_pages_write() does not handle the case where strsep finds no
delimiter in the given string and sets the input buffer to NULL, which
allows this reproducer to trigger a protection fault.

Link: https://lkml.kernel.org/r/20241216042752.257090-2-leocstone@gmail.com
Signed-off-by: Leo Stone <leocstone@gmail.com>
Reported-by: syzbot+8a3da2f1bbf59227c289@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8a3da2f1bbf59227c289
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c

index df0c4988dd88b1502c1d0121f112d327d2288c43..e53d83b3e5cf9702d5ddfaef7cd172a9a203e955 100644 (file)
@@ -4169,7 +4169,7 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf,
                size_t input_len = strlen(input_buf);
 
                tok = strsep(&buf, ",");
-               if (tok) {
+               if (tok && buf) {
                        strscpy(file_path, tok);
                } else {
                        ret = -EINVAL;