Skip to content

Commit caf3100

Browse files
Philipp Stannerdavem330
authored andcommitted
drivers/net/ppp: use standard array-copy-function
In ppp_generic.c, memdup_user() is utilized to copy a userspace array. This is done without an overflow-check, which is, however, not critical because the multiplicands are an unsigned short and struct sock_filter, which is currently of size 8. Regardless, string.h now provides memdup_array_user(), a wrapper for copying userspace arrays in a standardized manner, which has the advantage of making it more obvious to the reader that an array is being copied. The wrapper additionally performs an obligatory overflow check, saving the reader the effort of analyzing the potential for overflow, and making the code a bit more robust in case of future changes to the multiplicands len * size. Replace memdup_user() with memdup_array_user(). Suggested-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Philipp Stanner <pstanner@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f968c56 commit caf3100

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ppp/ppp_generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ static struct bpf_prog *get_filter(struct sock_fprog *uprog)
570570

571571
/* uprog->len is unsigned short, so no overflow here */
572572
fprog.len = uprog->len;
573-
fprog.filter = memdup_user(uprog->filter,
574-
uprog->len * sizeof(struct sock_filter));
573+
fprog.filter = memdup_array_user(uprog->filter,
574+
uprog->len, sizeof(struct sock_filter));
575575
if (IS_ERR(fprog.filter))
576576
return ERR_CAST(fprog.filter);
577577

0 commit comments

Comments
 (0)