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 C7E6244102; Wed, 29 May 2024 15:03:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6BBBC402CD; Wed, 29 May 2024 15:03:54 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by mails.dpdk.org (Postfix) with ESMTP id 38EAA402B9 for ; Wed, 29 May 2024 15:03:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716987834; x=1748523834; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=ahKAKK2nWi04QL9CvvkC/wE6E911n6AL7QuJJAL3tW4=; b=NWnr+6Deb206jHc7nn2ckF63QOiXMKDJY3OPdpaEZCkmd0iDpU8xtRTV Y8DkI3A+MOahJ33yTxtQ4Wvgfpr9KZmNH8tZf1IFMkDx3lHEMI6p9qW/W tngOaKgaCTn0doQBwV5xYXsEvj4sDsbGy2YGnYC1sYutJSz8/VARrQnfY kyCXhRA4h1fPKdTXK3K261i2Sp4iGSzQLW2cy8P2uI6qwL+vUzgA1WtS7 kRijZMgDYzeCKLtWv8wVlcJnjGqrNh/0EXXqB+RabKhLHtHnZq+oPzubD e8cQI5WTqgfaO+Ug/wuUWTJPUFoa447HxX3nhYyt688bVaV/5FfCnmyVL Q==; X-CSE-ConnectionGUID: PRR5QNjCTeeB/u5y05N6HQ== X-CSE-MsgGUID: 8QgAP1rXTQ+G8wuhTn4Iow== X-IronPort-AV: E=McAfee;i="6600,9927,11087"; a="13570879" X-IronPort-AV: E=Sophos;i="6.08,198,1712646000"; d="scan'208";a="13570879" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2024 06:03:53 -0700 X-CSE-ConnectionGUID: ADuDyhWxSyabaTem6Ipv/Q== X-CSE-MsgGUID: mTa888nzQPS9RaHDI3zEZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,198,1712646000"; d="scan'208";a="35510500" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmviesa009.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 29 May 2024 06:03:53 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 29 May 2024 06:03:52 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx612.amr.corp.intel.com (10.18.126.92) 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, 29 May 2024 06:03:52 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 29 May 2024 06:03:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H1DHXd4R28Nr9GYNHBKEF4DBhNO9d6X1ZF+k3c0QtZWIGAWxD3NkgGBycN2hsks5KLpklJ8bTEhOVLsZlXAdaw9giGbEAkG5UoiI7DYXp5wNtUtXrEJH0NsKnTsdSLqm7BYhS2PD3N+8iPHG00+Bw496b1YqpD552vNIYJMuaheFgyTgDQxg7G2zR2FT6TOuurwj+S6YyfwYBU4Fg9/0+NSzLLMf/y+ih6ORpWgtzyTyboA8Ov0B1m94GniZn0dKVPnsmzOUbUiWyF9dswlzg2moV8ZYdSpRvzwSKPVJMlNyf1My4nzpl4/vFTyvkCGhqNwSWFthFWzaw269ceIiDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=WAUp4wWbax2psI7MIv9sPgDV4r9CwbVmK2eItY3tJ90=; b=ZqVAuxZzgoBjDLoJ/JaRRHVV0d/0GesaSaHuxK8vSFtQJUFDBmYnlfC877EPdRpRE900XfIxxgwgFyp0VDqsB1yG3fkxP9610gbJmumZWD7MJZ7/n1dLmo0I6WNPtQDnon4S1y/s/Onf7zVLU+1Zai2EaVBa4D8uoP2Iy3herWLow9mIU1w9dWBnDKeECtdcrGPEkh7MKqtUj4Y1QyodLpA5ZYkb48kkcL2Qr0nh1OldRpmd2vtRjtzQJBtK5E+MYo03VX/VTiTN7+NS3J8ISvEMRQAoH4LZQVXf7Z4y8HgNrUSBHue8/env6drt/HklOMlk9hl+e7YhQx4XizxIaw== 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 PH0PR11MB5877.namprd11.prod.outlook.com (2603:10b6:510:141::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Wed, 29 May 2024 13:03:44 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%7]) with mapi id 15.20.7633.017; Wed, 29 May 2024 13:03:43 +0000 Date: Wed, 29 May 2024 14:03:39 +0100 From: Bruce Richardson To: Soumyadeep Hore CC: , Subject: Re: [PATCH 04/25] common/idpf: update in PTP message validation Message-ID: References: <20240528072839.867100-1-soumyadeep.hore@intel.com> <20240528072839.867100-5-soumyadeep.hore@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20240528072839.867100-5-soumyadeep.hore@intel.com> X-ClientProxiedBy: DB8PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:10:be::32) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|PH0PR11MB5877:EE_ X-MS-Office365-Filtering-Correlation-Id: 27c35341-24f4-4139-7a49-08dc7fdfc4a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|366007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?e2dMEHZg4nV3VGnL/qDvGwW1JyPm0h2mtgrVwvADaJIh0F++ZwMFpcinBo9k?= =?us-ascii?Q?1N3ULqwR/1AheDEAoUUqY9fRmLLuoxw2x6gT1o1m7ca336u7AVCXOZoYFLSL?= =?us-ascii?Q?eacy6xR7zv2w9DUtkjRGE5WE6hr/1MquzLIOG93nU6aPSdSgfJS3OM+6Ljl2?= =?us-ascii?Q?ad3+ddp8aTw8JiUG3xAzRYCKRe6QbeVrem5sOxYFDDY3s6RT2MmTJ05MIbOy?= =?us-ascii?Q?cjXO0YKl9zsNEJCRsXPXicqSEZOR/FqWV1ENcHnfBr8nUMN8KCAqI37eA/zo?= =?us-ascii?Q?gfpVMlyhiw1lbwVtaf5VWwsrCf6U5D34jPL9MVhm4sgwuzanqvzWU56nde3/?= =?us-ascii?Q?eqwI94CDz2bKaWR6b6VU1TSDgo0tgWbGmhSNZXoS1Didy5Ns5mwhDteUr6iS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3wNpYeIvMQ=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:(13230031)(1800799015)(366007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?X67zmPVPt/XtWP+VH+uf8YPbtFtp3E/U37/cAyP91LT8ibK2NYy3muRc221j?= =?us-ascii?Q?ilVFfJUWQs2AXytw7g1VTVol9e/XVV8ILwvSwXcR6ozSxY4eFblxQVYq8ihI?= =?us-ascii?Q?07oZLoycBRf+/8At6Eo0RRtndgf2kvxHPJpdhgt2TGWsQlVzVVQ3yzQEdGlN?= =?us-ascii?Q?vLo1zDSYIfGl61C+1DB5T8m/+V8iIcBM/6W53WZFZn1GRmQAAfewwd6+pUAj?= =?us-ascii?Q?UHZogTtwe3PpaFlHR/W/AMC7DnRjwBtWdJtTFJRdeBgRIsN8pRcCKXtu95gB?= =?us-ascii?Q?wC+Xs3HpF6yzmoEE7UpXGi5XK85jU2kETtJGWw6fAah0gfJw6Yc6y9k958jv?= =?us-ascii?Q?jWVXlpwPwPkm6RrlWfPBqJnVnrx3uPB2AHjXr1EXf81eg8NbVuOTEhfKK6yP?= =?us-ascii?Q?3HlXlQkcXRUL5IBukTZ2pkJ5OYcySWcdckGzb5v3ZHUXMLOyeAqZrTaT7Ew3?= =?us-ascii?Q?FxOE4QMGozpephNyollEIadk7M8nwLYP9X15gdSIyKeyX0dC+moZS+u2wdUF?= =?us-ascii?Q?ROS6VHOM+5BSJqfhrINs3XDAXJaNtaUGGLzb3ymSfoNGvhB0q7sxVC1UFnBX?= =?us-ascii?Q?TfHN3riwJnqpm3pDoa8HeMnNOfKHVBQtBltjC6RW0boo2wiVtygPF14Xocsw?= =?us-ascii?Q?mYK/2+nL4+rC4LzUUr4umreyrVdSE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?L/OvsVLnOMJFPRTlcmhZ+GgA9iovYRXt2NkYbnQKE7Uba+m/3ZmgHkJX257T?= =?us-ascii?Q?6w=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 27c35341-24f4-4139-7a49-08dc7fdfc4a6 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 13:03:43.4888 (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: YbnnyU6LSbPfFOITyVG6P/ZcocGegFd7XejuA9Sisosg4MHWHFQaCmZiSW53ynFLeUSWyDoXN8OxV4uRLzy1tqOpT/XnPwwbd8nxlHvFD0w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5877 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 Tue, May 28, 2024 at 07:28:34AM +0000, Soumyadeep Hore wrote: > When the message for getting timestamp latches is sent by the driver, > number of latches is equal to 0. Current implementation of message > validation function incorrectly notifies this kind of message length as > invalid. > This description doesn't seem to match what the code is doing here. The code change below is changing the check on the message length from checking for >88 bytes rather than >= 88 bytes. This doesn't seem to have anything to do with not returning error when latches == 0. That check is a few lines further in the code block and is unmodified by this patch: 1872 > case VIRTCHNL2_OP_GET_PTP_CAPS: 1873 > > valid_len = sizeof(struct virtchnl2_get_ptp_caps); 1874 1875 > > if (msglen >= valid_len) { 1876 > > > struct virtchnl2_get_ptp_caps *ptp_caps = 1877 > > > (struct virtchnl2_get_ptp_caps *)msg; 1878 1879 > > > if (ptp_caps->tx_tstamp.num_latches == 0) { This is the check for 0 ^^^^ 1880 > > > > err_msg_format = true; 1881 > > > > break; 1882 > > > } 1883 1884 > > > valid_len += ((ptp_caps->tx_tstamp.num_latches - 1) * 1885 > > > > sizeof(struct virtchnl2_ptp_tx_tstamp_entry)); But alowing num_latches == 0 would make this calculation overflow ^^^^ 1886 > > } 1887 > > break; > Signed-off-by: Soumyadeep Hore > --- > drivers/common/idpf/base/virtchnl2.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/common/idpf/base/virtchnl2.h b/drivers/common/idpf/base/virtchnl2.h > index f44c0965b4..9a1310ca24 100644 > --- a/drivers/common/idpf/base/virtchnl2.h > +++ b/drivers/common/idpf/base/virtchnl2.h > @@ -1873,7 +1873,7 @@ virtchnl2_vc_validate_vf_msg(__rte_unused struct virtchnl2_version_info *ver, u3 > case VIRTCHNL2_OP_GET_PTP_CAPS: > valid_len = sizeof(struct virtchnl2_get_ptp_caps); > > - if (msglen >= valid_len) { > + if (msglen > valid_len) { > struct virtchnl2_get_ptp_caps *ptp_caps = > (struct virtchnl2_get_ptp_caps *)msg; > > @@ -1889,7 +1889,7 @@ virtchnl2_vc_validate_vf_msg(__rte_unused struct virtchnl2_version_info *ver, u3 > case VIRTCHNL2_OP_GET_PTP_TX_TSTAMP_LATCHES: > valid_len = sizeof(struct virtchnl2_ptp_tx_tstamp_latches); > > - if (msglen >= valid_len) { > + if (msglen > valid_len) { > struct virtchnl2_ptp_tx_tstamp_latches *tx_tstamp_latches = > (struct virtchnl2_ptp_tx_tstamp_latches *)msg; > > -- > 2.43.0 >