Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3510831rwb; Mon, 16 Jan 2023 08:57:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXe+U+VtChwhTzJaqL4SntQhI6/fcX0ijq0h24zZYBOuF861iju0Ebhx/LkJxA+tKNMf9s X-Received: by 2002:a17:90a:df98:b0:226:f291:a27e with SMTP id p24-20020a17090adf9800b00226f291a27emr22161286pjv.3.1673888274495; Mon, 16 Jan 2023 08:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673888274; cv=none; d=google.com; s=arc-20160816; b=XDbJ+mGNnPITnXBknKJqD0++F0ytbXgHTW917Rv5SiisOCy/xKla29/CRs0VQx/xgN QJwtxs1PL5H8FegNAUBf6r0mBG97vfRlNyYG1EqO9qUNkkERTbphqxwmPYpbEPfcQtjN S4NmTG6qu0Zvr3QkFfMBUYbFXFQkvYM9LsJFHqj91lCkuBzUbfveIdWegxBVGmN4PKBq 5cLpqkicU8msTyjvnFrjRN1qeeUvWpLll14AcPR6xhY2XJekzUJqI6rMFbYw4ToLfK+/ QC0Ed4NF/WC8DrmbnBG2VhKvW1UI7FNLSe6JKoXuYHV1GTGaJwAJYg0kp6OLjGOz4zbC kW/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Zji24U9iJ0v7SHNqSmcwo+z7LPA1SbzRkaEn/QxyL8Q=; b=Xidd0HvHWHAAEdtgONtdZufYlmWn551AuCM+/GiGEONLFyNSTpUDIlA9fn48L6bAB5 gQBADgNYGWJ3McZwN+OQskxqghOKwgrZRe38JfFKFDeqeK0oLaeQqSiV4Q+ylO8CiWrz 6SKXD/n5mk621lfVef7kxwHK6SQVHQDSemuzhd+5Jrdf8ViO2ipoc7j5UliZX7FeZlwu p21RNtIHvK+MASZD2RXJO8+ms9n/UGJUUq6tFkwkIWdLvP/sd6Jqs1s9VsD1Yti5Z60B kfCEnpk/ZJVKy9DjbZQA0VMAvm7hFZ16fJhDic0ezVwva6YDnZHLXXffz6jwZaEecvI4 jxbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=FAkHzwaZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l4-20020a17090a850400b00226d70e3ad9si28287890pjn.14.2023.01.16.08.57.46; Mon, 16 Jan 2023 08:57:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@yandex-team.ru header.s=default header.b=FAkHzwaZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbjAPPoM (ORCPT + 52 others); Mon, 16 Jan 2023 10:44:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbjAPPn7 (ORCPT ); Mon, 16 Jan 2023 10:43:59 -0500 Received: from forwardcorp1b.mail.yandex.net (forwardcorp1b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:df01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6BE21C33D; Mon, 16 Jan 2023 07:43:58 -0800 (PST) Received: from sas1-7470331623bb.qloud-c.yandex.net (sas1-7470331623bb.qloud-c.yandex.net [IPv6:2a02:6b8:c08:bd1e:0:640:7470:3316]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 2841B5DC24; Mon, 16 Jan 2023 18:21:14 +0300 (MSK) Received: from davydov-max-nux.yandex.net (unknown [2a02:6b8:0:107:fa75:a4ff:fe7d:8480]) by sas1-7470331623bb.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 0LllA20WE0U1-UPo9vtdS; Mon, 16 Jan 2023 18:21:13 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1673882473; bh=Zji24U9iJ0v7SHNqSmcwo+z7LPA1SbzRkaEn/QxyL8Q=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=FAkHzwaZVzPp7bzrRNxMpyadVP3E7E7DhJJXSPl2OXvXLxxcGp9st7IVnXOAxEwSJ 0ldgMjI/gjFqygnjbsl26u5QA5bq2wMMF4seQEkY221Uwo4bSihbHUnHVi1YEEoSdl wtuxBgFytpDHNZk7vXs7PYq+pnUlP4JU28xbxAOg= Authentication-Results: sas1-7470331623bb.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Maksim Davydov To: rajur@chelsio.com Cc: davydov-max@yandex-team.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, anish@chelsio.com, hariprasad@chelsio.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 1/2] net/ethernet/chelsio: fix cxgb4_getpgtccfg wrong memory access Date: Mon, 16 Jan 2023 18:20:59 +0300 Message-Id: <20230116152100.30094-2-davydov-max@yandex-team.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230116152100.30094-1-davydov-max@yandex-team.ru> References: <20230116152100.30094-1-davydov-max@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-kernel@vger.kernel.org *pgid can be in range 0 to 0xF (bitmask 0xF) but valid values for PGID are between 0 and 7. Also the size of pgrate is 8. Thus, we are needed additional check to make sure that this code doesn't have access to tsa. Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Fixes: 76bcb31efc06 ("cxgb4 : Add DCBx support codebase and dcbnl_ops") Signed-off-by: Maksim Davydov --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c index 7d5204834ee2..3aa65f0f335e 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c @@ -471,7 +471,10 @@ static void cxgb4_getpgtccfg(struct net_device *dev, int tc, return; } - *bw_per = pcmd.u.dcb.pgrate.pgrate[*pgid]; + /* Valid values are: 0-7 */ + if (*pgid <= 7) + *bw_per = pcmd.u.dcb.pgrate.pgrate[*pgid]; + *up_tc_map = (1 << tc); /* prio_type is link strict */ -- 2.25.1