From: Ryder Lee <Ryder.Lee@mediatek.com>
To: "keescook@chromium.org" <keescook@chromium.org>
Cc: "MeiChia Chiu (邱美嘉)" <MeiChia.Chiu@mediatek.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"gustavo@embeddedor.com" <gustavo@embeddedor.com>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-hardening@vger.kernel.org"
<linux-hardening@vger.kernel.org>,
"Shayne Chen (陳軒丞)" <Shayne.Chen@mediatek.com>,
"nbd@nbd.name" <nbd@nbd.name>,
"lorenzo@kernel.org" <lorenzo@kernel.org>,
"kuba@kernel.org" <kuba@kernel.org>,
"Sean Wang" <Sean.Wang@mediatek.com>,
"kvalo@kernel.org" <kvalo@kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"Sujuan Chen (陈素娟)" <Sujuan.Chen@mediatek.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-next@vger.kernel.org" <linux-next@vger.kernel.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"Bo Jiao (焦波)" <Bo.Jiao@mediatek.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: Coverity: mt7915_mcu_get_chan_mib_info(): Memory - illegal accesses
Date: Fri, 2 Dec 2022 23:42:36 +0000 [thread overview]
Message-ID: <6285b967a37d7f641b13ba73c10033450ee8ea7f.camel@mediatek.com> (raw)
In-Reply-To: <202212021504.A1942911@keescook>
On Fri, 2022-12-02 at 15:04 -0800, Kees Cook wrote:
> >
> On Fri, Dec 02, 2022 at 10:56:19PM +0000, Ryder Lee wrote:
> > On Fri, 2022-12-02 at 14:24 -0800, coverity-bot wrote:
> > > Hello!
> > >
> > > This is an experimental semi-automated report about issues
> > > detected
> > > by
> > > Coverity from a scan of next-20221202 as part of the linux-next
> > > scan
> > > project:
> > >
> >
> >
https://urldefense.com/v3/__https://scan.coverity.com/projects/linux-next-weekly-scan__;!!CTRNKA9wMg0ARbw!j7j_C0KpO4VD2yMOodvpeIexTGq4fhy2yq6nokNua9u4LToiUOLk4ou8JFFNrXkrh80d5BK2k44faRQstHE9$
> >
> > >
> > >
> > > You're getting this email because you were associated with the
> > > identified
> > > lines of code (noted below) that were touched by commits:
> > >
> > > Thu Feb 3 13:57:56 2022 +0100
> > > 417a4534d223 ("mt76: mt7915: update mt7915_chan_mib_offs for
> > > mt7916")
> > >
> > > Coverity reported the following:
> > >
> > > *** CID 1527801: Memory - illegal accesses (OVERRUN)
> > > drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:3005 in
> > > mt7915_mcu_get_chan_mib_info()
> > > 2999 start = 5;
> > > 3000 ofs = 0;
> > > 3001 }
> > > 3002
> > > 3003 for (i = 0; i < 5; i++) {
> > > 3004 req[i].band = cpu_to_le32(phy->mt76->band_idx);
> > > vvv CID 1527801: Memory - illegal accesses (OVERRUN)
> > > vvv Overrunning array "offs" of 9 4-byte elements at element
> > > index 9 (byte offset 39) using index "i + start" (which evaluates
> > > to
> > > 9).
> > > 3005 req[i].offs = cpu_to_le32(offs[i + start]);
> > > 3006
> > > 3007 if (!is_mt7915(&dev->mt76) && i == 3)
> > > 3008 break;
> > > 3009 }
> > > 3010
> > >
> > > If this is a false positive, please let us know so we can mark it
> > > as
> > > such, or teach the Coverity rules to be smarter. If not, please
> > > make
> > > sure fixes get into linux-next. :) For patches fixing this,
> > > please
> > > include these lines (but double-check the "Fixes" first):
> > >
> >
> > I think this is a false postive as the subsequent check 'if
> > (!is_mt7915(&dev->mt76) && i == 3)' should break array "offs" of 8.
>
> Ah, okay. What if is_mt7915(&dev->mt76) is always true?
>
> -Kees
int start = 0;
if (!is_mt7915(&dev->mt76)) {
start = 5;
ofs = 0;
}
for (i = 0; i < 5; i++) {
req[i].band = cpu_to_le32(phy->band_idx);
req[i].offs = cpu_to_le32(offs[i + start]);
if (!is_mt7915(&dev->mt76) && i == 3) //
break;
}
For 'is_mt7915' case, start:0 and i: 0 1 2 3 4, whereas !is_mt7915'
case, start:5 and i: 0 1 2 3 (then break).
I know it's a bit tricky. This is used to differentiate chipset
revision.
Ryder
WARNING: multiple messages have this Message-ID (diff)
From: Ryder Lee <Ryder.Lee@mediatek.com>
To: "keescook@chromium.org" <keescook@chromium.org>
Cc: "MeiChia Chiu (邱美嘉)" <MeiChia.Chiu@mediatek.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"gustavo@embeddedor.com" <gustavo@embeddedor.com>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"linux-hardening@vger.kernel.org"
<linux-hardening@vger.kernel.org>,
"Shayne Chen (陳軒丞)" <Shayne.Chen@mediatek.com>,
"nbd@nbd.name" <nbd@nbd.name>,
"lorenzo@kernel.org" <lorenzo@kernel.org>,
"kuba@kernel.org" <kuba@kernel.org>,
"Sean Wang" <Sean.Wang@mediatek.com>,
"kvalo@kernel.org" <kvalo@kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"Sujuan Chen (陈素娟)" <Sujuan.Chen@mediatek.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-next@vger.kernel.org" <linux-next@vger.kernel.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"Bo Jiao (焦波)" <Bo.Jiao@mediatek.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: Re: Coverity: mt7915_mcu_get_chan_mib_info(): Memory - illegal accesses
Date: Fri, 2 Dec 2022 23:42:36 +0000 [thread overview]
Message-ID: <6285b967a37d7f641b13ba73c10033450ee8ea7f.camel@mediatek.com> (raw)
In-Reply-To: <202212021504.A1942911@keescook>
On Fri, 2022-12-02 at 15:04 -0800, Kees Cook wrote:
> >
> On Fri, Dec 02, 2022 at 10:56:19PM +0000, Ryder Lee wrote:
> > On Fri, 2022-12-02 at 14:24 -0800, coverity-bot wrote:
> > > Hello!
> > >
> > > This is an experimental semi-automated report about issues
> > > detected
> > > by
> > > Coverity from a scan of next-20221202 as part of the linux-next
> > > scan
> > > project:
> > >
> >
> >
https://urldefense.com/v3/__https://scan.coverity.com/projects/linux-next-weekly-scan__;!!CTRNKA9wMg0ARbw!j7j_C0KpO4VD2yMOodvpeIexTGq4fhy2yq6nokNua9u4LToiUOLk4ou8JFFNrXkrh80d5BK2k44faRQstHE9$
> >
> > >
> > >
> > > You're getting this email because you were associated with the
> > > identified
> > > lines of code (noted below) that were touched by commits:
> > >
> > > Thu Feb 3 13:57:56 2022 +0100
> > > 417a4534d223 ("mt76: mt7915: update mt7915_chan_mib_offs for
> > > mt7916")
> > >
> > > Coverity reported the following:
> > >
> > > *** CID 1527801: Memory - illegal accesses (OVERRUN)
> > > drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:3005 in
> > > mt7915_mcu_get_chan_mib_info()
> > > 2999 start = 5;
> > > 3000 ofs = 0;
> > > 3001 }
> > > 3002
> > > 3003 for (i = 0; i < 5; i++) {
> > > 3004 req[i].band = cpu_to_le32(phy->mt76->band_idx);
> > > vvv CID 1527801: Memory - illegal accesses (OVERRUN)
> > > vvv Overrunning array "offs" of 9 4-byte elements at element
> > > index 9 (byte offset 39) using index "i + start" (which evaluates
> > > to
> > > 9).
> > > 3005 req[i].offs = cpu_to_le32(offs[i + start]);
> > > 3006
> > > 3007 if (!is_mt7915(&dev->mt76) && i == 3)
> > > 3008 break;
> > > 3009 }
> > > 3010
> > >
> > > If this is a false positive, please let us know so we can mark it
> > > as
> > > such, or teach the Coverity rules to be smarter. If not, please
> > > make
> > > sure fixes get into linux-next. :) For patches fixing this,
> > > please
> > > include these lines (but double-check the "Fixes" first):
> > >
> >
> > I think this is a false postive as the subsequent check 'if
> > (!is_mt7915(&dev->mt76) && i == 3)' should break array "offs" of 8.
>
> Ah, okay. What if is_mt7915(&dev->mt76) is always true?
>
> -Kees
int start = 0;
if (!is_mt7915(&dev->mt76)) {
start = 5;
ofs = 0;
}
for (i = 0; i < 5; i++) {
req[i].band = cpu_to_le32(phy->band_idx);
req[i].offs = cpu_to_le32(offs[i + start]);
if (!is_mt7915(&dev->mt76) && i == 3) //
break;
}
For 'is_mt7915' case, start:0 and i: 0 1 2 3 4, whereas !is_mt7915'
case, start:5 and i: 0 1 2 3 (then break).
I know it's a bit tricky. This is used to differentiate chipset
revision.
Ryder
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-12-02 23:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 22:24 Coverity: mt7915_mcu_get_chan_mib_info(): Memory - illegal accesses coverity-bot
2022-12-02 22:24 ` coverity-bot
2022-12-02 22:56 ` Ryder Lee
2022-12-02 22:56 ` Ryder Lee
2022-12-02 23:04 ` Kees Cook
2022-12-02 23:04 ` Kees Cook
2022-12-02 23:42 ` Ryder Lee [this message]
2022-12-02 23:42 ` Ryder Lee
2022-12-03 2:17 ` Kees Cook
2022-12-03 2:17 ` Kees Cook
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=6285b967a37d7f641b13ba73c10033450ee8ea7f.camel@mediatek.com \
--to=ryder.lee@mediatek.com \
--cc=Bo.Jiao@mediatek.com \
--cc=MeiChia.Chiu@mediatek.com \
--cc=Sean.Wang@mediatek.com \
--cc=Shayne.Chen@mediatek.com \
--cc=Sujuan.Chen@mediatek.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gustavo@embeddedor.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-next@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=nbd@nbd.name \
--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 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.