[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YkmBxD4H+tUgiuVg@kroah.com>
Date: Sun, 3 Apr 2022 13:15:16 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Charlie Sands <sandsch@...thvilleschools.net>
Cc: Larry.Finger@...inger.net, phil@...lpotter.co.uk,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: r8188eu: Fix unsafe memory access by memcmp.
On Fri, Apr 01, 2022 at 04:12:47PM -0400, 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@...thvilleschools.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;
Please do not add checkpatch issues when trying to fix up other issues
:(
And that's a very odd variable name you are creating. That is not a
pointer at all, and either way, it should not be part of a variable
name, this isn't Windows code :)
thanks,
greg k-h
Powered by blists - more mailing lists