lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202212061535.5D3DA489FB@keescook>
Date:   Tue, 6 Dec 2022 15:37:05 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Ryder Lee <Ryder.Lee@...iatek.com>
Cc:     Shayne Chen (陳軒丞) 
        <Shayne.Chen@...iatek.com>,
        StanleyYP Wang (王侑邦) 
        <StanleyYP.Wang@...iatek.com>,
        "linux-mediatek@...ts.infradead.org" 
        <linux-mediatek@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Howard-YH Hsu (許育豪) 
        <Howard-YH.Hsu@...iatek.com>,
        "gustavo@...eddedor.com" <gustavo@...eddedor.com>,
        Evelyn Tsai (蔡珊鈺) 
        <Evelyn.Tsai@...iatek.com>,
        Money Wang (王信安) 
        <Money.Wang@...iatek.com>,
        "linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>,
        "nbd@....name" <nbd@....name>,
        MeiChia Chiu (邱美嘉) 
        <MeiChia.Chiu@...iatek.com>,
        "lorenzo@...nel.org" <lorenzo@...nel.org>,
        "kuba@...nel.org" <kuba@...nel.org>,
        Sean Wang <Sean.Wang@...iatek.com>,
        "kvalo@...nel.org" <kvalo@...nel.org>,
        "edumazet@...gle.com" <edumazet@...gle.com>,
        Sujuan Chen (陈素娟) 
        <Sujuan.Chen@...iatek.com>,
        Chui-hao Chiu (邱垂浩) 
        <Chui-hao.Chiu@...iatek.com>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "pabeni@...hat.com" <pabeni@...hat.com>,
        "matthias.bgg@...il.com" <matthias.bgg@...il.com>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "linux-next@...r.kernel.org" <linux-next@...r.kernel.org>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
        Bo Jiao (焦波) <Bo.Jiao@...iatek.com>
Subject: Re: Coverity: mt7996_hw_queue_read(): Integer handling issues

On Sat, Dec 03, 2022 at 04:40:09AM +0000, Ryder Lee wrote:
> On Fri, 2022-12-02 at 14:11 -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!jBOoj6LMqqA8E0AyjKQTa-0rVzcFiZ3BbpciEIn7so974kcMBeG4zZm-QU4AudLXY7-jNUSt0unzAt2zirSF$ 
> >  
> > 
> > You're getting this email because you were associated with the
> > identified
> > lines of code (noted below) that were touched by commits:
> > 
> >   Thu Dec 1 17:29:14 2022 +0100
> >     98686cd21624 ("wifi: mt76: mt7996: add driver for MediaTek Wi-Fi
> > 7 (802.11be) devices")
> > 
> > Coverity reported the following:
> > 
> > *** CID 1527813:  Integer handling issues  (SIGN_EXTENSION)
> > drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c:460 in
> > mt7996_hw_queue_read()
> > 454     	for (i = 0; i < size; i++) {
> > 455     		u32 ctrl, head, tail, queued;
> > 456
> > 457     		if (val & BIT(map[i].index))
> > 458     			continue;
> > 459
> > vvv     CID 1527813:  Integer handling issues  (SIGN_EXTENSION)
> > vvv     Suspicious implicit sign extension: "map[i].qid" with type
> > "u8" (8 bits, unsigned) is promoted in "map[i].qid << 24" to type
> > "int" (32 bits, signed), then sign-extended to type "unsigned long"
> > (64 bits, unsigned).  If "map[i].qid << 24" is greater than
> > 0x7FFFFFFF, the upper bits of the result will all be 1.
> > 460     		ctrl = BIT(31) | (map[i].pid << 10) |
> > (map[i].qid << 24);
> 
> u32 ctrl = BIT(31) | (map[i].pid << 10) | (map[i].qid << 24);
> 
> Hmm ...where's type "int" (32 bits, signed) from?

	map[i].qid is promoted to int before the "<< 24".

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ