Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2777376rwb; Fri, 2 Dec 2022 15:06:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4XJ89w8JJlIgLGT6v3ODk2UPWtrFfr0N2OJYF7dHnYc5d5QdNme0+oi39R0a9pOLMiMMWp X-Received: by 2002:a17:902:934b:b0:189:78db:12be with SMTP id g11-20020a170902934b00b0018978db12bemr32776285plp.8.1670022406042; Fri, 02 Dec 2022 15:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670022406; cv=none; d=google.com; s=arc-20160816; b=xj6Tqv3/puxD6iYbC3ay9dSmOdNaVSr/9pOgxAfl/CQ6Kuio/GWByp7rZzbbQttikg jZGHO8FJbkOj9oC1gpYfTLoiE/146z+hlu8rE3mToJHh/nMgcM908+Wp98cGc8VMKUBP bT/vXHaHhg3V+4ygI3f6RUzLADih0nul/ANV+Tcqgz30rORCzls83vtvHXYsUnm6SM1B tEDQFwnH2rNZ1xDVnfO8IHwmFvZB7x2lhQmxvgx+0J8UD3rGT4mU9VsmAml47eIwVDse SRPEAA/grgDtcj2/5seNWHdk3dGGs1B4aNIRiMvXSHvKlzeZvTaL3LGIX6fH0Uw9OKau Zarw== 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=3eWdYeAABAMnoEoSZbvIqfAvjGuNN+NLL8O7DVcc5tw=; b=otekvxae+jCxzBzTnOrps/Fus76rQ8LQH4WnQjNrVeeCI5b2WByQRlJg6U269jds7X JZsC8lJm+kj1d4EXRrqizT25EJwOljCMYQRJhEJH7bhv5RH44s6KPcTrVQpzzmdk0Fcw VL2o/rodvb+zvvv+UxP0P011tNrs90h8+hvAJHI9xvLAxAaF+LAQ+7iwnjJk+yqnoRhu Wu0yXARoOBM7YJ0YwmwjnfinUVmJa2b3c+wyK6uhZKZjc1nfj6FOUskt3nwENroXqy2l Ieh8v5lv8TTx+o0hHkP9ro1dOZq1fn96imGnpsVNC9oFrYxIkom0HGJ5H0EuG2hhfYTx 3j+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LPDjcXKR; 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 n2-20020a170902d2c200b00189c6fbf963si403090plc.478.2022.12.02.15.06.31; Fri, 02 Dec 2022 15:06:46 -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=LPDjcXKR; 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 S234159AbiLBXEx (ORCPT + 66 others); Fri, 2 Dec 2022 18:04:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233221AbiLBXEw (ORCPT ); Fri, 2 Dec 2022 18:04:52 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C358DA7D2 for ; Fri, 2 Dec 2022 15:04:51 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id 21so6242440pfw.4 for ; Fri, 02 Dec 2022 15:04:51 -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=3eWdYeAABAMnoEoSZbvIqfAvjGuNN+NLL8O7DVcc5tw=; b=LPDjcXKRkJF0ChWSvwqdMs4z+WaNIJwO0yY5Q59nGeM3pDMHVwIb6cPYLQgWVJguAB ciAtCM4G0YFdDjeGOSSxDSrCrEHGWnroQqTT/uQy4yjM39FpLTUwFW+H4Sr88a8juay4 4lauU6rk4+hFPwNW6zqanjTHmoMbiFkIJBgIM= 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=3eWdYeAABAMnoEoSZbvIqfAvjGuNN+NLL8O7DVcc5tw=; b=XpVevgOYQANFV20kVHwAa7Sy8YtPtmn6UM6jsNQriqco1S6nbZSpJsWL3389HxvCzw Ncp39EVs1Aw+ss8MG+YvZzm8dTnSWDGPZSuDB8zIlyRTYqOwsXOIdTEsAf/rH1meIaHi LOwzBNKIxkU7P/3OtCIwyAr++ilagangR4+ZAIwOKXH+aFRdDXk73UtRVKZVaRUdl4Vo 53HJ7hws/GgwO8WlhrgoPDmf9ynfP9EtChEWiI/TrwUII6RUNOeokL3ITpNFvVAx7qAg VDHcyhlr4+7eobvY/5PieQY97L+RhA9WXTxfU6R4zz3EQ9PZZpZjce0zg8od0wmL4Zlm 763A== X-Gm-Message-State: ANoB5pnbbS10aaqoeNhx2trGTOh2vFxdFoCIYZ1Etv0m/uCrbrcJvcrY FdKl7SLcgBjcNWRhTxiEZHB+Cg== X-Received: by 2002:a63:e34b:0:b0:477:de0a:3233 with SMTP id o11-20020a63e34b000000b00477de0a3233mr34109179pgj.467.1670022291026; Fri, 02 Dec 2022 15:04:51 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c3-20020a17090a4d0300b00218998eb828sm7058622pjg.45.2022.12.02.15.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 15:04:50 -0800 (PST) Date: Fri, 2 Dec 2022 15:04:49 -0800 From: Kees Cook To: Ryder Lee Cc: Bo Jiao =?utf-8?B?KOeEpuazoik=?= , MeiChia Chiu =?utf-8?B?KOmCsee+juWYiSk=?= , "linux-mediatek@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "gustavo@embeddedor.com" , "linux-hardening@vger.kernel.org" , Shayne Chen =?utf-8?B?KOmZs+i7kuS4nik=?= , "nbd@nbd.name" , "lorenzo@kernel.org" , "kuba@kernel.org" , Sean Wang , "kvalo@kernel.org" , "edumazet@google.com" , Sujuan Chen =?utf-8?B?KOmZiOe0oOWonyk=?= , "pabeni@redhat.com" , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" , "linux-next@vger.kernel.org" , "matthias.bgg@gmail.com" , "davem@davemloft.net" , "linux-wireless@vger.kernel.org" Subject: Re: Coverity: mt7915_mcu_get_chan_mib_info(): Memory - illegal accesses Message-ID: <202212021504.A1942911@keescook> References: <202212021424.34C0F695E4@keescook> <1a16599dd5e4eed86bae112a232a3599af43a5f2.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: <1a16599dd5e4eed86bae112a232a3599af43a5f2.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=ham 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 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 > > Ryder > > > Reported-by: coverity-bot > > Addresses-Coverity-ID: 1527801 ("Memory - illegal accesses") > > Fixes: 417a4534d223 ("mt76: mt7915: update mt7915_chan_mib_offs for > > mt7916") > > > > Thanks for your attention! > > -- Kees Cook