]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ppp: fix out-of-bounds access in bpf_prog_create()
authorEric Biggers <ebiggers@google.com>
Thu, 5 Dec 2019 05:54:19 +0000 (21:54 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Dec 2019 22:45:19 +0000 (14:45 -0800)
sock_fprog_kern::len is in units of struct sock_filter, not bytes.

Fixes: 3e859adf3643 ("compat_ioctl: unify copy-in of ppp filters")
Reported-by: syzbot+eb853b51b10f1befa0b7@syzkaller.appspotmail.com
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ppp/ppp_generic.c

index 0cb1c2d0a8bcb84bf14eaffdef3235fbcbff89fb..3bf8a8b4298309dcf4843e4f94ba11ccb4d95ebb 100644 (file)
@@ -564,8 +564,9 @@ static struct bpf_prog *get_filter(struct sock_fprog *uprog)
                return NULL;
 
        /* uprog->len is unsigned short, so no overflow here */
-       fprog.len = uprog->len * sizeof(struct sock_filter);
-       fprog.filter = memdup_user(uprog->filter, fprog.len);
+       fprog.len = uprog->len;
+       fprog.filter = memdup_user(uprog->filter,
+                                  uprog->len * sizeof(struct sock_filter));
        if (IS_ERR(fprog.filter))
                return ERR_CAST(fprog.filter);