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 F01DD4588A; Wed, 28 Aug 2024 18:08:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7FE5242686; Wed, 28 Aug 2024 18:08:09 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by mails.dpdk.org (Postfix) with ESMTP id 2D935402CA for ; Wed, 28 Aug 2024 18:08:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724861287; x=1756397287; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=TYyBxDUW30SRQjLjp8wKu+8HAvYsv1l2TjieEvSvicU=; b=Yzan9TvpeeWOqBNKu6KrIjae9BFeehDv2cXHbPggQbfcFssYQ1bIWTuD 60BfI1a5/8hrYCvieIEhFUs8Jylh7HaFYJsrUKJjfwwMMb69C9BMOEhKG 1p5C6WQ28QeitCFaGipFmEwY0cL9X5hdkCGTEW2kCRxeFi6aMXxg0ZEeK 5Nt/Gc41DRpumd2w5JVHLvHdls1zcoN7FFurpQ7tIA/MFesKLPpbYCS9L 5VBGUBJUcdawWwVyJvkn6XXpUY/tNkYYZagOBwYLp3e66EojDihU8aCza pUQ7MlZux1o//FPlQlTGn/l7gMmMG6Ucg57DRT5Pxr6VCTAzAjCi9hkLy w==; X-CSE-ConnectionGUID: GVjnYT3GThWepadknCBF1g== X-CSE-MsgGUID: HRgudFwMSS24A3cM20FHtw== X-IronPort-AV: E=McAfee;i="6700,10204,11178"; a="34780855" X-IronPort-AV: E=Sophos;i="6.10,183,1719903600"; d="scan'208";a="34780855" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2024 09:05:24 -0700 X-CSE-ConnectionGUID: S5imQrB6QKuJML7TX6lv+Q== X-CSE-MsgGUID: Em2WMOPqRGSS0W+VTpx4xQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,183,1719903600"; d="scan'208";a="63115725" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa010.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 28 Aug 2024 09:05:24 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 28 Aug 2024 09:05:23 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 28 Aug 2024 09:05:18 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Wed, 28 Aug 2024 09:05:18 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.40) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 28 Aug 2024 09:05:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tTXwMhCEff83jkWOZJdlCG3f8JmmcEvRnrnwvCbrPBEHUMEF4zuZPgihU4GyrVnc/U3bPbLxenRLcSAdElXJFi/mBLkjN9ksQFyUlryiYjjubKdGVPhW+P/kc8U5gmYW1vqJ7UtZrcypJ4DGPWzydpdPHB5tTe1e1qRuFB+TgLcdSqG49p5gCytOpnAWgyjJt9XfHGVPJUxFDDVq6upGFgT4mHvZLhuLlUBpDn/3BIjPnhC7wj5LdZ+i0PFj2DBjc3J8xsvban0gZEfYicuH1Hn/nchxSIx1dZT5mhLlw+87s2n8J/wCwA7vtPxhEAoMBaEmKg4sv+3f2qWm0xSrmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QER5/JCNOkolBo/AW3m7/KAsmHqUdUCFmh/HxPRqdoI=; b=eukimYSYfH8PKFqg3CnhdjCI2PemEb4Rr9l7VO4pjNZjpeqLL1k4fx6Nn8rftx88wBILDL6yvNPTatpy5VrXBakklbfWlWvW0bpIiSJyMpaIJIlI4E7NmhcbCWmwZlzqo2O/BmH6xReP03k7NJfbHDkK7URymGp1on7FlHG4wwGR0EKK1h2TIaL0DYOY8pxUIluABHYcWtctzh/2yRZRZgBDgg+m50ZeN7Jz/vGEqE6wy2y4nzkya5pJgtouDMkVNho7SZSaZ5QCmXA00bK1pAyOj/Bw0gnAWVW/80MhV+HoTdqaT1/UH0ZqGQwdnP5fkRruMVFWSVFtgLJ83dAAUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by IA1PR11MB6220.namprd11.prod.outlook.com (2603:10b6:208:3e8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.25; Wed, 28 Aug 2024 16:05:11 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%2]) with mapi id 15.20.7897.021; Wed, 28 Aug 2024 16:05:10 +0000 Date: Wed, 28 Aug 2024 17:05:05 +0100 From: Bruce Richardson To: Soumyadeep Hore CC: , , , Subject: Re: [PATCH v3 08/12] net/ice: update iteration of TLVs in Preserved Fields Area Message-ID: References: <20240822185346.221885-13-soumyadeep.hore@intel.com> <20240823095650.349785-1-soumyadeep.hore@intel.com> <20240823095650.349785-9-soumyadeep.hore@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240823095650.349785-9-soumyadeep.hore@intel.com> X-ClientProxiedBy: DB7PR03CA0082.eurprd03.prod.outlook.com (2603:10a6:10:72::23) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|IA1PR11MB6220:EE_ X-MS-Office365-Filtering-Correlation-Id: 584b5c51-bfcb-42d4-f6ae-08dcc77b319e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Nh5xphDvHnQ/60ilbAUCoHqZAGsdWJd+8Kb2uocCjQPhxjjlnEpIyVEy8KaJ?= =?us-ascii?Q?6vqhHxTs2bJwS4WNiUVpYRTFRzd9f1dWtxYwW159jq04VmjfTyw79gmnKhzB?= =?us-ascii?Q?S4Sv8kvjS2IV+L7SxZ5TQLfmzzAbBB98ZPRGQ37HlTYMGealxxuQRTOILwg/?= =?us-ascii?Q?WGEMWtz0Ik6WOVoAWFSXlRKDjR68h1C1vluFUMneZpmRRzQ0+XS8uLscs7hW?= =?us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zm1xLlX9BhJ27Ip0lJe?= =?us-ascii?Q?f1Qn0x2h2yAJ7D8ivkrKPIrj6+62vJcrNyftbKThE736PcLdH4nmU89eUDn3?= =?us-ascii?Q?rVZhesDossWVnxULxt7w4/5GgTEO2QaA7TRbDW/EKlLLxMLYPcFSv8HuYId4?= =?us-ascii?Q?J4QpYWNe5it+5zUagQUyNQj+INLEThvHw3/BI6UaWYnXe+inUZYKBaFiy04W?= =?us-ascii?Q?b3Se9oDzGbmkgYrI5Sb671brXL5njxFRisjPc4w/ZiVN3g=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?SNo/bNtTf04Vnun399msifJDcW67VoD3p78g83u14wxzRskBJtJ9D19IGKAl?= =?us-ascii?Q?PLp4hHryIxWundq/on5bo5WZIkhae71F10l5pMSvcAhzzlWBaggs0ZQElLem?= =?us-ascii?Q?dA+bD3JI8sAh/GduP6sGSJCNKVoTcBpBD7n5aHuKRlVfAmNeDzS86+8WKWWv?= =?us-ascii?Q?S/sieVDwiOd++2HTOP4OSgsxcHYcMEmfjQFICnkFHN3icTErcD47w38qid5S?= =?us-ascii?Q?CS4ehR0tNfdpffBzVn5O8nkqe5TLOVkiEM6ZCdW+urdoRpPXV22Hp/FiXQJE?= =?us-ascii?Q?uhaFStHztqMvEGCu4I+CkFIw5PcY3gJY65sgNQ4Bgq+k528XLSspAg/xyphk?= =?us-ascii?Q?3aThYWy3Q/nfnfT00kWgmxBgzfYdL02z6/E0X8Bjo+ypmGouCcz8e6DHmqv3?= =?us-ascii?Q?0qmscGckuWOH7MYLAmZW10guWJ3s+aaBZglLd/Sw2j3Vtl9/gWBs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Qd8FguifVEypg6MuiLhXgg2xiNeb03csID4NhZp?= =?us-ascii?Q?Yx/pX5l0AYZ4ipq2dJ789mwhKo4YzpUwpJfuaLNzhOUa+rLUvGP1BCqeq0Ql?= =?us-ascii?Q?3CDylb1cUXdsGX3kK9QWqCIPHZfl14NhQU6d7piu4CiD81XAzIyre7qBqCRx?= =?us-ascii?Q?GtbyRnP3CvxagzGh0QRkTzNync6QGZcuWfGq1iRRuGtzSGHmIRF3CSfbydrF?= =?us-ascii?Q?E2USrc7PitqWgjsKq6CndeQcXtgnTWfRY89xZozJdNV0Ql4QfCxM7V0rbiUO?= =?us-ascii?Q?rA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 584b5c51-bfcb-42d4-f6ae-08dcc77b319e X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 16:05:10.8557 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FDVgJMK2JKviZTP6EeoaiP8h/mkzASF2LLur5KTppg0gc9PsVSB2OCMdKCsq8yOE7aBSDAOPumm74PB1sXn6Y0R1C+DwMnmfgd2Eg6/byA0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB6220 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, Aug 23, 2024 at 09:56:46AM +0000, Soumyadeep Hore wrote: > From: Fabio Pricoco > > Correct the logic for determining the maximum PFA offset to include the > extra last word. Additionally, make the driver robust against overflows > by using check_add_overflow. This ensures that even if the NVM > provides bogus data, the driver will not overflow, and will instead log > a useful warning message. The check for whether the TLV length exceeds the > PFA length is also removed, in favor of relying on the overflow warning > instead. > > Signed-off-by: Fabio Pricoco > Signed-off-by: Soumyadeep Hore > --- > drivers/net/ice/base/ice_nvm.c | 29 ++++++++++++++++++----------- > 1 file changed, 18 insertions(+), 11 deletions(-) > > diff --git a/drivers/net/ice/base/ice_nvm.c b/drivers/net/ice/base/ice_nvm.c > index 0124cef04c..56c6c96a95 100644 > --- a/drivers/net/ice/base/ice_nvm.c > +++ b/drivers/net/ice/base/ice_nvm.c > @@ -469,6 +469,8 @@ int ice_read_sr_word(struct ice_hw *hw, u16 offset, u16 *data) > return status; > } > > +#define check_add_overflow __builtin_add_overflow > + > /** > * ice_get_pfa_module_tlv - Reads sub module TLV from NVM PFA > * @hw: pointer to hardware structure > @@ -484,8 +486,7 @@ int > ice_get_pfa_module_tlv(struct ice_hw *hw, u16 *module_tlv, u16 *module_tlv_len, > u16 module_type) > { > - u16 pfa_len, pfa_ptr; > - u32 next_tlv; > + u16 pfa_len, pfa_ptr, next_tlv, max_tlv; > int status; > > status = ice_read_sr_word(hw, ICE_SR_PFA_PTR, &pfa_ptr); > @@ -498,6 +499,13 @@ ice_get_pfa_module_tlv(struct ice_hw *hw, u16 *module_tlv, u16 *module_tlv_len, > ice_debug(hw, ICE_DBG_INIT, "Failed to read PFA length.\n"); > return status; > } > + > + if (check_add_overflow(pfa_ptr, (u16)(pfa_len - 1), &max_tlv)) { > + ice_debug(hw, ICE_DBG_INIT, "PFA starts at offset %u. PFA length of %u caused 16-bit arithmetic overflow.\n", > + pfa_ptr, pfa_len); > + return ICE_ERR_INVAL_SIZE; > + } > + > /* The Preserved Fields Area contains a sequence of TLVs which define > * its contents. The PFA length includes all of the TLVs, plus its > * initial length word itself, *and* one final word at the end of all > @@ -507,7 +515,7 @@ ice_get_pfa_module_tlv(struct ice_hw *hw, u16 *module_tlv, u16 *module_tlv_len, > * of TLVs to find the requested one. > */ > next_tlv = pfa_ptr + 1; > - while (next_tlv < ((u32)pfa_ptr + pfa_len - 1)) { > + while (next_tlv < max_tlv) { This is essentially overwriting the change made in patch 4 of this set - except for the comment change. Therefore, I believe patches 4 and 8 should be merged to avoid touching this line of code multiple times. /Bruce