From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A728045B14 for ; Fri, 11 Oct 2024 18:45:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9785540611; Fri, 11 Oct 2024 18:45:19 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by mails.dpdk.org (Postfix) with ESMTP id 8D8914060F; Fri, 11 Oct 2024 18:45:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728665118; x=1760201118; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uv4IEmmiw7//AY7pXwG5gKDbgPEQWADj67mG9cMjRSY=; b=PV7yUsrV8/xpAC7nq9r6/iN57KdCoNuzUiOp70Bt5CJ4R+N4BFQf3NaS H+1E9jqLDEAscz61LEUNATL2+BJ21pASvJs1D4o284NQ2FlYA957qiL56 a/tU3Pdbdqfy588umYE+NpulAHf+EJmBWIXL36/LAMdYkGtqFpWHtAT4I dVpfyEZZDk8zN7U/19Tgn1JkCSOqCSt1MybLX6PHvxE142GPVtCEM6JFt UnFsEk6+slc6D8IsNpyHxeeK8FaS1x08lTNFvDaqtjysTBzgQny21y4ce wDIgqfI4+4PkEOLJv0U+o26/+7CUE7kFW5nzAr1cECDF2JbNtcVPBCqRC Q==; X-CSE-ConnectionGUID: OkkpDbENS/qt/+a8CaHl2g== X-CSE-MsgGUID: yCxg6lFZQCybYM9I55Zd+g== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="53477051" X-IronPort-AV: E=Sophos;i="6.11,196,1725346800"; d="scan'208";a="53477051" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2024 09:45:17 -0700 X-CSE-ConnectionGUID: C41rPgRfTyaT0IHiudFp6w== X-CSE-MsgGUID: Yj/VZABNTbCoK4lNzrD1gw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,196,1725346800"; d="scan'208";a="76609298" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.25]) by fmviesa007.fm.intel.com with ESMTP; 11 Oct 2024 09:45:16 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Fabio Pricoco , stable@dpdk.org, Bruce Richardson Subject: [PATCH 2/9] net/ice/base: add bounds check Date: Fri, 11 Oct 2024 17:44:52 +0100 Message-ID: <20241011164459.1987538-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241011164459.1987538-1-bruce.richardson@intel.com> References: <20241011164459.1987538-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Fabio Pricoco Refactor while loop to add a check that the values read are in the correct range. Fixes: 6c1f26be50a2 ("net/ice/base: add control queue information") Cc: stable@dpdk.org Signed-off-by: Fabio Pricoco Signed-off-by: Bruce Richardson --- drivers/net/ice/base/ice_controlq.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/net/ice/base/ice_controlq.c b/drivers/net/ice/base/ice_controlq.c index af27dc8542..b210495827 100644 --- a/drivers/net/ice/base/ice_controlq.c +++ b/drivers/net/ice/base/ice_controlq.c @@ -839,16 +839,35 @@ static u16 ice_clean_sq(struct ice_hw *hw, struct ice_ctl_q_info *cq) struct ice_ctl_q_ring *sq = &cq->sq; u16 ntc = sq->next_to_clean; struct ice_aq_desc *desc; + u32 head; desc = ICE_CTL_Q_DESC(*sq, ntc); - while (rd32(hw, cq->sq.head) != ntc) { - ice_debug(hw, ICE_DBG_AQ_MSG, "ntc %d head %d.\n", ntc, rd32(hw, cq->sq.head)); + head = rd32(hw, sq->head); + if (head >= sq->count) { + ice_debug(hw, ICE_DBG_AQ_MSG, + "Read head value (%d) exceeds allowed range.\n", + head); + return 0; + } + + while (head != ntc) { + ice_debug(hw, ICE_DBG_AQ_MSG, + "ntc %d head %d.\n", + ntc, head); ice_memset(desc, 0, sizeof(*desc), ICE_DMA_MEM); ntc++; if (ntc == sq->count) ntc = 0; desc = ICE_CTL_Q_DESC(*sq, ntc); + + head = rd32(hw, sq->head); + if (head >= sq->count) { + ice_debug(hw, ICE_DBG_AQ_MSG, + "Read head value (%d) exceeds allowed range.\n", + head); + return 0; + } } sq->next_to_clean = ntc; -- 2.43.0