From: Zong-Zhe Yang <kevin_yang@realtek.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Ping-Ke Shih <pkshih@realtek.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: RE: [PATCH next] wifi: rtw89: mcc: prevent shift wrapping in rtw89_core_mlsr_switch()
Date: Tue, 27 May 2025 07:58:13 +0000 [thread overview]
Message-ID: <c70e23c6e9134f7e8b8791b5ece6baa3@realtek.com> (raw)
In-Reply-To: <aDVtu6dpKfWOyBn6@stanley.mountain>
Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> On Tue, May 27, 2025 at 07:38:17AM +0000, Zong-Zhe Yang wrote:
> > Dan Carpenter <dan.carpenter@linaro.org> wrote:
> > >
> > > The "link_id" value comes from the user via debugfs. If it's larger
> > > than BITS_PER_LONG then that would result in shift wrapping and
> > > potentially an out of bounds access later. Fortunately, only root can write to debugfs files
> so the security impact is minimal.
> > >
> >
> > Thank you for catching this problem.
> >
> > >
> > > [...]
> > >
> > > @@ -5239,6 +5239,9 @@ int rtw89_core_mlsr_switch(struct rtw89_dev
> > > *rtwdev, struct rtw89_vif *rtwvif,
> > > if (unlikely(!ieee80211_vif_is_mld(vif)))
> > > return -EOPNOTSUPP;
> > >
> > > + if (unlikely(link_id >= BITS_PER_LONG))
> > > + return -EINVAL;
> > > +
> >
> > Since I think this problem only comes from dbgfs path, would you like to just add a check in
> debug.c ?
> >
> > For example,
> > (based on 0 <= valid link id < IEEE80211_MLD_MAX_NUM_LINKS <
> > BITS_PER_LONG)
> >
> > rtw89_debug_priv_mlo_mode_set(...)
> > {
> > ...
> > switch (mlo_mode) {
> > case RTW89_MLO_MODE_MLSR:
> > if (argv >= IEEE80211_MLD_MAX_NUM_LINKS)
> > return -EINVAL;
> > ...
> >
>
> I'd prefer to add the check in one place instead of all the callers.
Understandable.
> We could check IEEE80211_MLD_MAX_NUM_LINKS instead of bits per long if that's more
> readable?
Sound good to me.
prev parent reply other threads:[~2025-05-27 7:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 5:56 Dan Carpenter
2025-05-27 7:38 ` Zong-Zhe Yang
2025-05-27 7:46 ` Dan Carpenter
2025-05-27 7:58 ` Zong-Zhe Yang [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=c70e23c6e9134f7e8b8791b5ece6baa3@realtek.com \
--to=kevin_yang@realtek.com \
--cc=dan.carpenter@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.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®