From: "Nicolas Escande" <nico.escande@gmail.com>
To: "Wentao Liang" <vulab@iscas.ac.cn>, <johannes@sipsolutions.net>,
<luciano.coelho@intel.com>
Cc: <linux-wireless@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] mac80211: Add null pointer check for ieee80211_link_get_chanctx()
Date: Mon, 26 May 2025 10:25:33 +0200 [thread overview]
Message-ID: <DA5Y65C1FEEX.1YVIUHMANNAYC@gmail.com> (raw)
In-Reply-To: <20250525164211.2039-1-vulab@iscas.ac.cn>
On Sun May 25, 2025 at 6:42 PM CEST, Wentao Liang wrote:
> The function ieee80211_chsw_switch_vifs() calls the function
> ieee80211_link_get_chanctx(), but does not check its return value.
> The return value is a null pointer if the ieee80211_link_get_chanctx()
> fails. This will lead to a null pointer dereference in the following
> code "&old_ctx->conf". A proper implementation can be found in
> ieee80211_link_use_reserved_assign().
>
> Add a null pointer check and goto error handling path if the
> function fails.
>
> Fixes: 5d52ee811019 ("mac80211: allow reservation of a running chanctx")
> Cc: stable@vger.kernel.org # v3.16
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> net/mac80211/chan.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
> index a442cb667520..9e6235001e0a 100644
> --- a/net/mac80211/chan.c
> +++ b/net/mac80211/chan.c
> @@ -1503,6 +1503,10 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,
> continue;
>
> old_ctx = ieee80211_link_get_chanctx(link);
> + if (WARN_ON(old_ctx)) {
Don't you mean 'if (WARN_ON(!old_ctx)) {'
> + err = -EINVAL;
> + goto out;
> + }
> vif_chsw[i].vif = &link->sdata->vif;
> vif_chsw[i].old_ctx = &old_ctx->conf;
> vif_chsw[i].new_ctx = &ctx->conf;
prev parent reply other threads:[~2025-05-26 8:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-25 16:42 [PATCH] mac80211: Add null pointer check for ieee80211_link_get_chanctx() Wentao Liang
2025-05-26 8:25 ` Nicolas Escande [this message]
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=DA5Y65C1FEEX.1YVIUHMANNAYC@gmail.com \
--to=nico.escande@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=luciano.coelho@intel.com \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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.