Skip to content

Commit 0033b34

Browse files
ebiggersdavem330
authored andcommitted
ppp: fix out-of-bounds access in bpf_prog_create()
sock_fprog_kern::len is in units of struct sock_filter, not bytes. Fixes: 3e859ad ("compat_ioctl: unify copy-in of ppp filters") Reported-by: [email protected] Signed-off-by: Eric Biggers <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a116f4e commit 0033b34

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/ppp/ppp_generic.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,9 @@ static struct bpf_prog *get_filter(struct sock_fprog *uprog)
564564
return NULL;
565565

566566
/* uprog->len is unsigned short, so no overflow here */
567-
fprog.len = uprog->len * sizeof(struct sock_filter);
568-
fprog.filter = memdup_user(uprog->filter, fprog.len);
567+
fprog.len = uprog->len;
568+
fprog.filter = memdup_user(uprog->filter,
569+
uprog->len * sizeof(struct sock_filter));
569570
if (IS_ERR(fprog.filter))
570571
return ERR_CAST(fprog.filter);
571572

0 commit comments

Comments
 (0)