mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Philipp Hortmann <philipp.g.hortmann@gmail.com>,
	Lee Jones <lee@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	Larry Finger <Larry.Finger@lwfinger.net>,
	Johannes Berg <johannes@sipsolutions.net>,
	Kalle Valo <kvalo@kernel.org>,
	Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [RFC] staging: wlan-ng: Driver broken since kernel 5.15
Date: Mon, 18 Mar 2024 11:01:12 +0300	[thread overview]
Message-ID: <cbdb25ca-f419-4afe-9b58-7d274445aefd@moroto.mountain> (raw)
In-Reply-To: <5716d138-ace0-4621-ab34-118610255207@app.fastmail.com>

On Sun, Mar 17, 2024 at 09:20:34PM +0100, Arnd Bergmann wrote:
> On Sun, Mar 17, 2024, at 21:07, Philipp Hortmann wrote:
> > On 3/11/24 08:04, Dan Carpenter wrote:
> >> On Sat, Mar 09, 2024 at 11:09:24PM +0100, Philipp Hortmann wrote:
> > You are right with the statement that it is this commit.
> > commit ea82ff749587807fa48e3277c977ff3cec266f25 (HEAD)
> > Author: Lee Jones <lee.jones@linaro.org>
> > Date:   Wed Apr 14 19:10:39 2021 +0100
> >
> >      staging: wlan-ng: cfg80211: Move large struct onto the heap
> >
> >      Fixes the following W=1 kernel build warning(s):
> >
> >       drivers/staging/wlan-ng/cfg80211.c: In function ‘prism2_scan’:
> >       drivers/staging/wlan-ng/cfg80211.c:388:1: warning: the frame size 
> > of 1296 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> >
> > But It is not depending on the line you pointed to.
> 
> Right, the kzalloc() already clears the data, so the memset
> is not needed.
> 

No, it's inside a loop so it needs to be cleared on each iteration.

> > I need another week to look into this.
> 
> I'm fairly sure this fixes the bug, the problem here was that
> the cast to (u8 *) hides the incorrect conversion:
> 
> diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c
> index 471bb310176f..9d6a2dd35ba9 100644
> --- a/drivers/staging/wlan-ng/cfg80211.c
> +++ b/drivers/staging/wlan-ng/cfg80211.c
> @@ -350,7 +350,7 @@ static int prism2_scan(struct wiphy *wiphy,
>  		msg2->msgcode = DIDMSG_DOT11REQ_SCAN_RESULTS;
>  		msg2->bssindex.data = i;
>  
> -		result = p80211req_dorequest(wlandev, (u8 *)&msg2);
> +		result = p80211req_dorequest(wlandev, (u8 *)msg2);

Ah, well done.

It feels like this is the kind of bug which should be caught with
static analysis.  One of the things that people want from static
analysis is looking at what a patch does.  So if we pass &msg2 and the
patch moved msg from the stack to be kmalloc()ed, then print a warning.
It's not something that Smatch does.

I have my rename_rev.pl script (https://github.com/error27/rename_rev)
which I use to filter out variable renames or see if (1 << foo) is
converted to BIT(foo) correctly.  Maybe I could extend that to check
"move stack to heap" patches...

regards,
dan carpenter


  reply	other threads:[~2024-03-18  8:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09 22:09 Philipp Hortmann
2024-03-11  7:04 ` Dan Carpenter
2024-03-17 20:07   ` Philipp Hortmann
2024-03-17 20:20     ` Arnd Bergmann
2024-03-18  8:01       ` Dan Carpenter [this message]
2024-03-18  8:30         ` Arnd Bergmann
2024-03-18 17:07         ` Philipp Hortmann
2024-03-12 15:57 ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cbdb25ca-f419-4afe-9b58-7d274445aefd@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=julia.lawall@inria.fr \
    --cc=kvalo@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=philipp.g.hortmann@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®