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 smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 496A4C4332F for ; Wed, 21 Dec 2022 18:30:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C783E81A92; Wed, 21 Dec 2022 18:30:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C783E81A92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1671647406; bh=UnA/AQ/il+13HMEos5EoJTShh1bfuEK7PqiNkykTM0w=; h=Date:From:To:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=hwdI0ZJ3millif0AWA2iPVBH55UeH1u68p3+olB9PA2zchrODUCeFtPk0MeR//W4Q 5tlcxN6YpEv97DVAcCwFQkRSeJ4mnIXP/u8SqeAtUZjaGRaHDaBHG1FK8xZTc1LpZJ BcngEGilvbXPDoAjycWkjtIAZBpi3FIWwwXv5CEU9QZyJcXFosCf2WGOinPY8NCBg2 +VlJNXSpNFbH7hUyJ0ePxVRZwd43l8+BLeEBYr+fw8zHUCOipKS1Rrp+ZXWVho6mvp SXPNRxNHk8RE5figxekeFrZqwowrhoK6Q3G4bPtb6Qq1oMhAmgr5x2NylEjXu1Jbvk XBXiJtwoOgtvA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DdyPwBePx2hw; Wed, 21 Dec 2022 18:30:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id B930D81ABB; Wed, 21 Dec 2022 18:30:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B930D81ABB Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id D38B91BF3A6 for ; Wed, 21 Dec 2022 18:30:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id ACE9D40441 for ; Wed, 21 Dec 2022 18:30:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org ACE9D40441 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TvoIE1_2D0tQ for ; Wed, 21 Dec 2022 18:30:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 47611400A6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp2.osuosl.org (Postfix) with ESMTPS id 47611400A6 for ; Wed, 21 Dec 2022 18:30:03 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6500,9779,10568"; a="321859575" X-IronPort-AV: E=Sophos;i="5.96,263,1665471600"; d="scan'208";a="321859575" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2022 10:29:42 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10568"; a="651496238" X-IronPort-AV: E=Sophos;i="5.96,263,1665471600"; d="scan'208";a="651496238" Received: from unknown (HELO localhost.localdomain) ([10.237.112.144]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2022 10:29:41 -0800 Date: Wed, 21 Dec 2022 19:29:37 +0100 From: Michal Swiatkowski To: Alexander Lobakin Message-ID: References: <20221221092746.39234-1-michal.swiatkowski@linux.intel.com> <20221221163726.1189622-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221221163726.1189622-1-alexandr.lobakin@intel.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671647403; x=1703183403; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=o0T7fEa4BFjY9aJrHYnlZTnN2gBl4bUxn8WXwSDtCZo=; b=JC3YSi1R0f/MYJvWUFxGituu8n/CcRsTGC81blYfvl8Hp3As8zXXPesq j8yfVAiPWwQhPzFxQhHgfEz/Q1k++E3H34docvz/Le0LlgxW4i2xuF0l+ pq+PY830uMIQGO3IiexFamDqaaMaVJkiv94uYxA0bBok50CWMjpkX5miL niNHuxlXv5TyDSUKR6DYlw0ccHiXA7Iwaz/QdrKHiE+q1jG9yOuPISPNY STFNcXmLl9vWCd3SFnFSTaEs3b0V0LV4lHph1bUjRI1kf1jiN7rr78vI6 fRpDqBhH9LzUqqSVazma+/YZEhDG6nGK4vxod2/JYe0OXgq+YgJtJ4GRc w==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=JC3YSi1R Subject: Re: [Intel-wired-lan] [PATCH net] ice: fix out-of-bounds KASAN warining in virtchnl X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-wired-lan@lists.osuosl.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On Wed, Dec 21, 2022 at 05:37:26PM +0100, Alexander Lobakin wrote: > From: Michal Swiatkowski > Date: Wed, 21 Dec 2022 10:27:46 +0100 > > > KASAN reported: > > [ 9793.708867] BUG: KASAN: global-out-of-bounds in ice_get_link_speed+0x16/0x30 [ice] > > [ 9793.709205] Read of size 4 at addr ffffffffc1271b1c by task kworker/6:1/402 > > > > [ 9793.709222] CPU: 6 PID: 402 Comm: kworker/6:1 Kdump: loaded Tainted: G B OE 6.1.0+ #3 > > [ 9793.709235] Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.00.01.0014.070920180847 07/09/2018 > > [ 9793.709245] Workqueue: ice ice_service_task [ice] > > [...] > > > diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c > > index 4b78bfb0d7f9..a24b5cb95039 100644 > > --- a/drivers/net/ethernet/intel/ice/ice_common.c > > +++ b/drivers/net/ethernet/intel/ice/ice_common.c > > @@ -5562,7 +5562,7 @@ bool ice_fw_supports_report_dflt_cfg(struct ice_hw *hw) > > * returned by the firmware is a 16 bit * value, but is indexed > > * by [fls(speed) - 1] > > */ > > -static const u32 ice_aq_to_link_speed[15] = { > > +static const u32 ice_aq_to_link_speed[] = { > > SPEED_10, /* BIT(0) */ > > SPEED_100, > > SPEED_1000, > > @@ -5577,7 +5577,8 @@ static const u32 ice_aq_to_link_speed[15] = { > > 0, > > 0, > > 0, > > - 0 /* BIT(14) */ > > + 0, > > + 0 /* BIT(15) */ > > }; > > I warned Jesse that no index check might cause out-of-bounds walks > and here they are. I suggested the following back then: > > 1) Don't define any zeroed elements and elements with > %VIRTCHNL_LINK_SPEED_UNKNOWN. Don't define explicit array bounds. > > 2) In ice_get_link_speed(): > > if (index >= ARRAY_SIZE(ice_aq_to_link_speed)) > return 0; > > return ice_aq_to_link_speed[index]; > > 3) Same in ice_conv_link_speed_to_virtchnl(): > > u32 index = fls(link_speed) - 1; > > if (adv_link_support) > return ice_get_link_speed(index); > else if (index < ARRAY_SIZE(ice_legacy_aq_to_vc_speed)) > return ice_legacy_aq_to_vc_speed[index]; > else > return VIRTCHNL_LINK_SPEED_UNKNOWN; > > This could go as a fix to net with no problems. > Sounds reasonable, I will do it in next version, thanks. > > > > /** > > diff --git a/drivers/net/ethernet/intel/ice/ice_vf_mbx.c b/drivers/net/ethernet/intel/ice/ice_vf_mbx.c > > index d4a4001b6e5d..5f754d41f345 100644 > > --- a/drivers/net/ethernet/intel/ice/ice_vf_mbx.c > > +++ b/drivers/net/ethernet/intel/ice/ice_vf_mbx.c > > [...] > > > -- > > 2.36.1 > > Thanks, > Olek _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan