From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1040C352A1 for ; Tue, 6 Dec 2022 23:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q+/XcDLeZ5ZUmxs31Rxq3BePwTKZUH8902dnHZGoxww=; b=WsQKJDA6uimv0x coqCZXvxsArX/d7xrS/6KROzQYICk1GQLB9G8SVff/5Po+c/dFswpHxfhWy3EVm+i6Jfm0jyJOtAt Aye2niU6dGV3HT7SaNPjvYnnUxnr6AXql0wcW1ivBMnImrbbEbUZX9F8qIIbKCbTke4yrQOoLRAdY v8h+1zr/FzMa7GcLSx+QI1+E9Wv+vV0OMvM2WojXYeKwZPS9OUrmluZXmcRSk27LElUOTNpyYLHYi 43zvo6TIPZ6oAmtB9ctSaPdW9JV8cbannVJDNrAnAvm1vTxaEXws3xIILcQV53UXa6MzGmI3FdJTq 1eEUrYubwr5qB5XKmiZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2hUv-005KwD-7P; Tue, 06 Dec 2022 23:37:13 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2hUr-005Kgu-1u for linux-arm-kernel@lists.infradead.org; Tue, 06 Dec 2022 23:37:10 +0000 Received: by mail-pj1-x1035.google.com with SMTP id z8-20020a17090abd8800b00219ed30ce47so5278554pjr.3 for ; Tue, 06 Dec 2022 15:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=otCW253l7ot84a9vVRmiVoG+lIxgrQNkYbdDhCOtC9c=; b=haGQ+FidVA17wTfx2NQ/Pqq/OpXe0/1Dzr59IUgqxAZNDk/WVBWDpcWJ3Z0fulUStb c9584Lh0t96uOzS0fNsUaG3BeUFW/tFfU14Y5naNZYWEGRdecx0Ipv+sGXFNxH6hWuys qqWvECLFxx4lkR87n0Itr+zaBfL1HXV8FGs7A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=otCW253l7ot84a9vVRmiVoG+lIxgrQNkYbdDhCOtC9c=; b=FVqH4Oxpx1t4n7Qtvad+TjSj5/RCP+S3miK5cv/YVXLdCO3EWLHpxWuh5dPpB+X79c g93ZzXbureKXMpreK7f7WlTttN40gyM+zimUuWlA3GJ7RVScYbWyugyufexUObG6XXr6 Hz/ab7dJ9q1V4kDSVXssc+5b5WIu1KmfUD6eKNXwQZDucBTim1NsumQ8SyEGs5JaNH1D 6BjHNH7KwICZfi3Db2Tprm3Ce3ksNLzj4R4KPQHszlKArD/hL3XyHuVcynoc1D2mkzRo vW8NanhIQfm8FCxkHxBgZ65AA8XOUKvyC3sgfE2PSDnVO0i/sg114oNbd6K6pqmsDllY 3nIQ== X-Gm-Message-State: ANoB5pmmPk2k8lfZpbWDi5BpE/+ePpATtKuRasCt6eF04xSEdCe7+nMP gZ/72oNGgomwWcQy+65DDMSwzA== X-Google-Smtp-Source: AA0mqf4q1OYKyKIO9N36w2rvWCO+pr3fDJLBXlCWFivm02RH39BnlErnrXEIOx2DhnvBhvDcTwOt7w== X-Received: by 2002:a17:90a:d383:b0:219:c8d3:c503 with SMTP id q3-20020a17090ad38300b00219c8d3c503mr14436340pju.65.1670369827082; Tue, 06 Dec 2022 15:37:07 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w10-20020a62820a000000b00574cf11aaf3sm12178022pfd.208.2022.12.06.15.37.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 15:37:06 -0800 (PST) Date: Tue, 6 Dec 2022 15:37:05 -0800 From: Kees Cook To: Ryder Lee Cc: Shayne Chen =?utf-8?B?KOmZs+i7kuS4nik=?= , StanleyYP Wang =?utf-8?B?KOeOi+S+kemCpik=?= , "linux-mediatek@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Howard-YH Hsu =?utf-8?B?KOioseiCsuixqik=?= , "gustavo@embeddedor.com" , Evelyn Tsai =?utf-8?B?KOiUoeePiumIuik=?= , Money Wang =?utf-8?B?KOeOi+S/oeWuiSk=?= , "linux-hardening@vger.kernel.org" , "nbd@nbd.name" , MeiChia Chiu =?utf-8?B?KOmCsee+juWYiSk=?= , "lorenzo@kernel.org" , "kuba@kernel.org" , Sean Wang , "kvalo@kernel.org" , "edumazet@google.com" , Sujuan Chen =?utf-8?B?KOmZiOe0oOWonyk=?= , Chui-hao Chiu =?utf-8?B?KOmCseWegua1qSk=?= , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" , "pabeni@redhat.com" , "matthias.bgg@gmail.com" , "davem@davemloft.net" , "linux-next@vger.kernel.org" , "linux-wireless@vger.kernel.org" , Bo Jiao =?utf-8?B?KOeEpuazoik=?= Subject: Re: Coverity: mt7996_hw_queue_read(): Integer handling issues Message-ID: <202212061535.5D3DA489FB@keescook> References: <202212021411.A5E618D3@keescook> <786eff1a1751a5bc0dc68d6567be585b635bddb1.camel@mediatek.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <786eff1a1751a5bc0dc68d6567be585b635bddb1.camel@mediatek.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221206_153709_332717_AB1BA25B X-CRM114-Status: GOOD ( 17.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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-0rVzcFiZ3BbpciEIn7so= 974kcMBeG4zZm-QU4AudLXY7-jNUSt0unzAt2zirSF$=A0 > > = > > = > > 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 =3D 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 =3D BIT(31) | (map[i].pid << 10) | > > (map[i].qid << 24); > = > u32 ctrl =3D 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel