Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8201237rwb; Tue, 6 Dec 2022 15:40:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf42PoKRmRjW6MiO9bOiJvPlRSvmnKItxYp4rfgWnPgX12m6nYiW1Wmrn7dOs4q7sBa/TyM2 X-Received: by 2002:a05:6402:181:b0:461:ea0c:e151 with SMTP id r1-20020a056402018100b00461ea0ce151mr65117943edv.376.1670370054954; Tue, 06 Dec 2022 15:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670370054; cv=none; d=google.com; s=arc-20160816; b=BfLSv5TtE559jLCWYRr/bdt/WCFimzv8d+K6BwVQc/RYKS05Oa8g/y/vWfDC6QhcLg xwDVwLXEU71zdXFFrUIWNI+fr/Le5am5xXWyEspQXZIT0VlHHfBDf/L9GgbBYiFM3pQu uCyUlaHFGSvPgtdZEPvJataVI7FMVXr07NhTdqTbAg7vdkn28qMJHNwDsld5nqQ78HDW 7IWW4JWr7782l1GYBY301e9Asznbb8VSc6FF+Q3TdlGd1U2mxa41DiXan+CzOaf50/HO ihB9LysoLXnPJwFYXO4PNM/nLq+tGvcNZHbqxDbB3WzK10prMtDSPlmpQ7kktCRM6OhI KBuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=otCW253l7ot84a9vVRmiVoG+lIxgrQNkYbdDhCOtC9c=; b=rjqKX6rKfNksCsIRfwVrkOWWyTkXZPtAKyluoowVvQNpPqSLS2ga2s2HmcZo1wKDJP Dj0/r+OEsTybtlmcHXr1gycvmizd2iRlCJ56JGTIARrbudLPPLM75XjT/H6IJiaXwyEX fvbVGIYTdS/SDqUZHpmE4VN8N7Y9q62D65sswzCI/BmJ3zp7hDC2cLh7zWM0t4+TPcil 3dV/Ph3U76yG3yIcMSghzm/WCWrec+2BIhyO569pTSyzSvuTnqusAe4gtdFjUibWCqdp VrFIV9fN2FSMmuENoALIE2VfO6C/Ocn9kzyr55x9SPatSHH/5NQzEsqjOHG1ftS3mx/+ MEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=haGQ+Fid; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs10-20020a170906dc8a00b007c10ac8f9afsi3002373ejc.807.2022.12.06.15.40.30; Tue, 06 Dec 2022 15:40:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=haGQ+Fid; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229627AbiLFXhM (ORCPT + 66 others); Tue, 6 Dec 2022 18:37:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbiLFXhJ (ORCPT ); Tue, 6 Dec 2022 18:37:09 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9190942992 for ; Tue, 6 Dec 2022 15:37:07 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id m4so8540367pls.4 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=T+k8VcZ5JMfgPMuhDg8eojYXlQVAM15usJFN4ITaTrXOboCFn5AMH8DRS0VqS1vOtQ 8VGEwVGrDA4ADt83hDBA6K72xZGN/wun+zdcflun9yzOWQ6asloq3waNIFxOgTZVp4so i6fdceKRSigGy3eQVk8qzSYUXtf0uRCHHtlWzXjZ8Ubp1E/SvAi/V5URdnGMO0c3dvjc +HQSj5Jtdz6xm/OSFQHIMKrQyjZcslgO7asm/cZAADhXFtzIlonJVqYT+w1OGENaH14R 8RJf92lB28G8IQ+Gcc/2a6NKxO0Fny8pnLB5+mj9PIeVeqC977TMMfHqZb0ok58hRFpa 01IA== X-Gm-Message-State: ANoB5pm6RGRUJfz7Z5HNEJ/itMgHbXviNw2uv9oMHUDjg3FhP/rhVeb/ uRG7harVECbKi5gIYzjuIfLzhA== 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <786eff1a1751a5bc0dc68d6567be585b635bddb1.camel@mediatek.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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-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