All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: Li Tuo <islituo@gmail.com>
Cc: amit karwar <amitkarwar@gmail.com>,
	Ganapathi Bhat <ganapathi017@gmail.com>,
	Sharvari Harisangam <sharvari.harisangam@nxp.com>,
	Xinming Hu <huxinming820@gmail.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-wireless <linux-wireless@vger.kernel.org>,
	"<netdev@vger.kernel.org>" <netdev@vger.kernel.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	baijiaju1990@gmail.com
Subject: Re: [BUG] mwifiex: possible null-pointer dereference in mwifiex_dnld_cmd_to_fw()
Date: Mon, 2 Aug 2021 13:44:41 -0700	[thread overview]
Message-ID: <CA+ASDXPYbCFsu0zoTafgc3atHvK1TAx=S_NTkfb0UNtKwuZOZQ@mail.gmail.com> (raw)
In-Reply-To: <968036b8-df27-3f22-074b-3aeed7c7bbf2@gmail.com>

Hi,

On Fri, Jul 30, 2021 at 9:13 PM Li Tuo <islituo@gmail.com> wrote:
> Our static analysis tool finds a possible null-pointer dereference in
> the mwifiex driver in Linux 5.14.0-rc3:

Wouldn't be the first time a static analysis tool tripped up over
excessively redundant "safety" checks :)

For example:
https://lore.kernel.org/linux-wireless/20210731163546.10753-1-len.baker@gmx.com/T/#u

> The variable cmd_node->cmd_skb->data is assigned to the variable
> host_cmd, and host_cmd is checked in:
> 190:    if (host_cmd == NULL || host_cmd->size == 0)
>
> This indicates that host_cmd can be NULL.
> If so, the function mwifiex_recycle_cmd_node() will be called with the
> argument cmd_node:
> 196:    mwifiex_recycle_cmd_node(adapter, cmd_node);
>
> In this called function, the variable cmd_node->cmd_skb->data is
> assigned to the variable host_cmd, too.
> Thus the variable host_cmd in the function mwifiex_recycle_cmd_node()
> can be also NULL.
> However, it is dereferenced when calling le16_to_cpu():
> 144:    le16_to_cpu(host_cmd->command)
>
> I am not quite sure whether this possible null-pointer dereference is
> real and how to fix it if it is real.
> Any feedback would be appreciated, thanks!

I doubt it's real; the NULL check is probably excessive. I don't think
there's any case in which such skb's will have no ->data. If you're
interested, you could test and submit a "fix" to drop the excess
check.

Brian

  reply	other threads:[~2021-08-02 20:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31  4:13 [BUG] mwifiex: possible null-pointer dereference in mwifiex_dnld_cmd_to_fw() Li Tuo
2021-08-02 20:44 ` Brian Norris [this message]
2021-08-03  2:34   ` Li Tuo
  -- strict thread matches above, loose matches on Subject: below --
2021-07-31  3:45 Li Tuo

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='CA+ASDXPYbCFsu0zoTafgc3atHvK1TAx=S_NTkfb0UNtKwuZOZQ@mail.gmail.com' \
    --to=briannorris@chromium.org \
    --cc=amitkarwar@gmail.com \
    --cc=baijiaju1990@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ganapathi017@gmail.com \
    --cc=huxinming820@gmail.com \
    --cc=islituo@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sharvari.harisangam@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.