From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F103C433B4 for ; Sat, 24 Apr 2021 06:00:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 400026137D for ; Sat, 24 Apr 2021 06:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbhDXGA4 (ORCPT ); Sat, 24 Apr 2021 02:00:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:40514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbhDXGAx (ORCPT ); Sat, 24 Apr 2021 02:00:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 652086137D; Sat, 24 Apr 2021 06:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1619244016; bh=5y+JNpXhdcfwvkMSZyc1L+mhCIh3vzIaCOc/xaucCOk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rIIzwE/f2Z1g/HvP86RIhBhxWazNn9/1G1J7uaQXCDlT5QcRqDTdG0Bh6CEH5mHfk PnoqjNrOVbg7b6ixi8Fz0+qwstkc1iIeOHJu4AWD9dZ2t1YjCE/PX9Jd4ezokXZT+4 zUIyw2QyKZVAGPZ8M7S9DGNmPpP8U9WQlvI6AQZI= Date: Sat, 24 Apr 2021 08:00:10 +0200 From: Greg Kroah-Hartman To: Ashish Kalra Cc: Abheek Dhawan , Johannes Weiner , Romain Perier , Waiman Long , Allen Pais , Ivan Safonov , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: wlan-ng: silence incorrect type in argument 1 (different address spaces) warning Message-ID: References: <20210420090142.GA4086@ashish-NUC8i5BEH> <20210423152619.GA2469@ashish-NUC8i5BEH> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210423152619.GA2469@ashish-NUC8i5BEH> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 23, 2021 at 08:56:19PM +0530, Ashish Kalra wrote: > On Thu, Apr 22, 2021 at 10:43:13AM +0200, Greg Kroah-Hartman wrote: > > On Tue, Apr 20, 2021 at 02:31:42PM +0530, Ashish Kalra wrote: > > > Upon running sparse, "warning: incorrect type in argument 1 (different address spaces) > > > is brought to notice for this file.let's add correct typecast to make it cleaner and > > > silence the Sparse warning. > > > > > > Signed-off-by: Ashish Kalra > > > --- > > > drivers/staging/wlan-ng/p80211netdev.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c > > > index 6f9666dc0277..70570e8a5ad2 100644 > > > --- a/drivers/staging/wlan-ng/p80211netdev.c > > > +++ b/drivers/staging/wlan-ng/p80211netdev.c > > > @@ -569,7 +569,7 @@ static int p80211knetdev_do_ioctl(struct net_device *dev, > > > goto bail; > > > } > > > > > > - msgbuf = memdup_user(req->data, req->len); > > > + msgbuf = memdup_user((void __user *)req->data, req->len); > > > > Why isn't data being declared as a __user pointer to start with? Why is > > the cast needed here? > > > > This feels wrong as if it is papering over the real problem. > > > > thanks, > > > > greg k-h > Thanks for your inputs > variable data in structure p80211ioctl_req is used only inside this function and is > already casted to void __user * for copy_to_user. Should it be changed > to void __user from caadr_t inside p80211ioctl.h. it should be same at runtime > > --- a/drivers/staging/wlan-ng/p80211ioctl.h > +++ b/drivers/staging/wlan-ng/p80211ioctl.h > @@ -81,7 +81,7 @@ > > struct p80211ioctl_req { > char name[WLAN_DEVNAMELEN_MAX]; > - caddr_t data; > + void __user *data; > > Does this looks ok to you and is there any other check possible if this is ok? Wait, what is "caddr_t"? Try unwinding that mess first...