Commit 0033b34a authored by Eric Biggers's avatar Eric Biggers Committed by David S. Miller

ppp: fix out-of-bounds access in bpf_prog_create()

sock_fprog_kern::len is in units of struct sock_filter, not bytes.

Fixes: 3e859adf ("compat_ioctl: unify copy-in of ppp filters")
Reported-by: syzbot+eb853b51b10f1befa0b7@syzkaller.appspotmail.com
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a116f4e2
...@@ -564,8 +564,9 @@ static struct bpf_prog *get_filter(struct sock_fprog *uprog) ...@@ -564,8 +564,9 @@ static struct bpf_prog *get_filter(struct sock_fprog *uprog)
return NULL; return NULL;
/* uprog->len is unsigned short, so no overflow here */ /* uprog->len is unsigned short, so no overflow here */
fprog.len = uprog->len * sizeof(struct sock_filter); fprog.len = uprog->len;
fprog.filter = memdup_user(uprog->filter, fprog.len); fprog.filter = memdup_user(uprog->filter,
uprog->len * sizeof(struct sock_filter));
if (IS_ERR(fprog.filter)) if (IS_ERR(fprog.filter))
return ERR_CAST(fprog.filter); return ERR_CAST(fprog.filter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment