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 3118045B37 for ; Mon, 14 Oct 2024 13:03:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BFB14065E; Mon, 14 Oct 2024 13:03:04 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) by mails.dpdk.org (Postfix) with ESMTP id C70204042C; Mon, 14 Oct 2024 13:02:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728903781; x=1760439781; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uv4IEmmiw7//AY7pXwG5gKDbgPEQWADj67mG9cMjRSY=; b=Qx4oXXl27ZscgdrDH2vSOqLji7EGt6WXfF+YrH0x40XRD2FFnuTnoKMb Q5gvDGQW351A+UpDHF5fHAzl+zLAlkbrxC9TlvdGLrSWIMsaS0tC7ZQ+p uvI0Nz0nKp3z0C1Oa3KNzxpezs/xsoShPuq2QYYsVzJv1Z9FaPgLLgk8b JRo6KGZQpih0pg2UaGZ2O7tykZ2KjPkGCFBR+GAPLgbV8Hjj3XU19PdM4 PZxi1SaktxuyI2XJAhd5Or96ygR7UCaA6Choh8BgEUOo9SE1yFmQURCVc TT1yEWcIK5yzbdlgh0wtAFZ1I8Qcsh6RVf47hQ9c5CexN3KausH7utd5r A==; X-CSE-ConnectionGUID: fAAUsMrURxCvO8YNr3KKAA== X-CSE-MsgGUID: us06nJy9TXu0pPRF4FcxjA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="28340326" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="28340326" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2024 04:03:00 -0700 X-CSE-ConnectionGUID: uSHy9lv3Q0aoEfRZV1K+IA== X-CSE-MsgGUID: qPVwk5UiQXWXrD1vMOLPBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,202,1725346800"; d="scan'208";a="77167088" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.25]) by fmviesa006.fm.intel.com with ESMTP; 14 Oct 2024 04:02:58 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Fabio Pricoco , stable@dpdk.org, Bruce Richardson Subject: [PATCH v2 02/10] net/ice/base: add bounds check Date: Mon, 14 Oct 2024 12:02:06 +0100 Message-ID: <20241014110250.2314727-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014110250.2314727-1-bruce.richardson@intel.com> References: <20241011164459.1987538-1-bruce.richardson@intel.com> <20241014110250.2314727-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