public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Jia-Ju Bai <baijiaju@buaa.edu.cn>
Cc: johannes@sipsolutions.net, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: mac80211: Add NULL checks for sta->sdata
Date: Tue, 21 Mar 2023 09:36:23 +0100	[thread overview]
Message-ID: <ZBlsh0JFBagmPNCA@corigine.com> (raw)
In-Reply-To: <9b213efb-8c7a-497d-2e08-f404d174a6ae@buaa.edu.cn>

On Tue, Mar 21, 2023 at 03:40:40PM +0800, Jia-Ju Bai wrote:
> Hello Simon,
> 
> Thanks for the reply!
> 
> 
> On 2023/3/21 0:49, Simon Horman wrote:
> > On Mon, Mar 20, 2023 at 09:35:33PM +0800, Jia-Ju Bai wrote:
> > > In a previous commit 69403bad97aa, sta->sdata can be NULL, and thus it
> > > should be checked before being used.
> > Please run checkpatch on this patch, and correct the commit description
> > style.
> > 
> > ./scripts/checkpatch.pl -g HEAD
> > ERROR: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 69403bad97aa ("wifi: mac80211: sdata can be NULL during AMPDU start")'
> > #6:
> > In a previous commit 69403bad97aa, sta->sdata can be NULL, and thus it
> 
> Okay, I will revise it and run checkpatch.

Thanks.

> > > However, in the same call stack, sta->sdata is also used in the
> > > following functions:
> > > 
> > > ieee80211_ba_session_work()
> > >    ___ieee80211_stop_rx_ba_session(sta)
> > >      ht_dbg(sta->sdata, ...); -> No check
> > >      sdata_info(sta->sdata, ...); -> No check
> > >      ieee80211_send_delba(sta->sdata, ...) -> No check
> > >    ___ieee80211_start_rx_ba_session(sta)
> > >      ht_dbg(sta->sdata, ...); -> No check
> > >      ht_dbg_ratelimited(sta->sdata, ...); -> No check
> > >    ieee80211_tx_ba_session_handle_start(sta)
> > >      sdata = sta->sdata; if (!sdata) -> Add check by previous commit
> > >    ___ieee80211_stop_tx_ba_session(sdata)
> > >      ht_dbg(sta->sdata, ...); -> No check
> > >    ieee80211_start_tx_ba_cb(sdata)
> > >      sdata = sta->sdata; local = sdata->local -> No check
> > >    ieee80211_stop_tx_ba_cb(sdata)
> > >      ht_dbg(sta->sdata, ...); -> No check
> > I wonder if it would be better to teach ht_* do do nothing
> > if the first argument is NULL.
> 
> Okay, I will use this way in patch v2.

Maybe it is not a good idea.
But I think it is worth trying, at least locally, to see how it goes.

> > Also, are these theoretical bugs?
> > Or something that has been observed?
> > And has a reproducer?
> 
> These bugs are found by my static analysis tool, by extending a known bug
> fixed in a previous commit 69403bad97aa.
> Thus, they could be theoretical bugs.

Thanks, understood.
I think it would be worth making that a bit clearer in the
patch description (commit message).

> > > Thus, to avoid possible null-pointer dereferences, the related checks
> > > should be added.
> > > 
> > > These results are reported by a static tool designed by myself.
> > > 
> > > Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> > > Reported-by: TOTE Robot <baijiaju@buaa.edu.cn>
> > I see 4 copies of this patch in a few minutes.
> > As per the FAQ [1], please leave at least 24h between posts of a patch.
> > 
> > [1] https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
> 
> I am quite sorry for this, because my script of git send email was buggy.
> I noticed this problem after sending the e-mail, and now I have fixed it :)

Thanks, I realised after I sent my previous email that something like that
might have happened. Thanks for fixing it.

  reply	other threads:[~2023-03-21  8:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 13:38 [PATCH] net: mac80211: Add NULL checks for sta->sdata Jia-Ju Bai
2023-03-20 13:36 ` Jia-Ju Bai
2023-03-20 13:36   ` Jia-Ju Bai
2023-03-20 13:35     ` Jia-Ju Bai
2023-03-20 16:49       ` Simon Horman
2023-03-21  7:40         ` Jia-Ju Bai
2023-03-21  8:36           ` Simon Horman [this message]
2023-03-21  9:37             ` Jia-Ju Bai

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=ZBlsh0JFBagmPNCA@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=baijiaju@buaa.edu.cn \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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