lkml.org 
[lkml]   [2022]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] staging: r8188eu: Fix unsafe memory access by memcmp.
From
Hi Charlie,

On 4/1/22 23:12, Charlie Sands wrote:
> This patch fixes sparse warnings about the memcmp function unsafely
> accessing userspace memory without first copying it to kernel space.
>
> Signed-off-by: Charlie Sands <sandsch@northvilleschools.net>
> ---
> drivers/staging/r8188eu/os_dep/ioctl_linux.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> index 7df213856d66..1cfac1b27eb7 100644
> --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c
> @@ -3233,23 +3233,27 @@ static int rtw_p2p_get(struct net_device *dev,
> struct iw_request_info *info,
> union iwreq_data *wrqu, char *extra)
> {
> - if (!memcmp(wrqu->data.pointer, "status", 6)) {
> + char wrqu_data_ptr[9];
> + if (copy_from_user(wrqu_data_ptr, wrqu->data.pointer, 9))
> + return 0;

-EFAULT is standard return value in case of `copy_{to_from}_user` failure



With regards,
Pavel Skripkin

\
 
 \ /
  Last update: 2022-04-03 13:21    [W:0.052 / U:0.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site