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 C1D26A054A; Fri, 23 Sep 2022 02:46:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 663BB400D7; Fri, 23 Sep 2022 02:46:23 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 9336D4003C for ; Fri, 23 Sep 2022 02:46:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663893981; x=1695429981; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=bCdK98zQAdZJ7/XFFcO3VvHF1Q4sV+uSLOmd3CvIYP8=; b=H7GTUnTNj0qCbgcTAiZTQD4mrudV1y3W9CHu9Kkh67AQ9xEpsBtvqIbh h7x2HlL5e4SENZqhilw+KKEHfd/vQiqDwWEZ9rcLxWf4buRfKVTTw7CVI A4PvHFW3sYNB0VWmp4l3Q5tgAZrxjawOnhofxPZSu+dGyfBd+SwEQv8Be a0HASRVz/UoHrG6QNUhXX2q92TMWNY8PuMChW7qo8SLVQ9093D3Ud6P4/ AwqZsCW6EHi9B0mmp3V9j173w+bNPZs4qvYUgBXWt24YLmBGVjcK84e+V sTur3uQLV74sy4Onl4OQoLM0XBpjcLsMwhzMvGFOSaylWxk/UoD249MIN w==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="280841539" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="280841539" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 17:46:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="709113216" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by FMSMGA003.fm.intel.com with ESMTP; 22 Sep 2022 17:46:20 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 17:46:20 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.2375.31; Thu, 22 Sep 2022 17:46:19 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Thu, 22 Sep 2022 17:46:19 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.43) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Thu, 22 Sep 2022 17:46:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZMbjoFgKPIBiFGCSPYvlo/5ekYzatZc8bSzmXwUnEgQ02ZWME9bh8HpF9lF1dAkQidSDcBtELVoSmAW/7ns6x5TeLLY9nisP+4JZvUDpdvadP0ZzYgdxgUtLU9qy7aZfahMRVSxVeGJzNigkvQSrUBAkHN5OzyKzCVIyhzUvGqrllygJSNS332tHKrxh9xL+4/Gl6RD1RcShL7m/PYd4AZ5y+h6K5Tj2fYs2dgJ6jr3crTGdGSNtpsodN5c47iJH2nPffKbdkrhvC1pPo2hfLb30MTsBMbc9zm3lYZRErmPmzMMAa14PEhNWJx1QmNhOuY2fK6QsH4josSg2YLRDSA== 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=spf0+FOqrIMYlOnpstr5ywPMNcW5bvDcpLpE4nrAqrM=; b=QG4ogy5C6YQRQjLyf7rAi0bRzVc49w305BYAqufJH26BiYAu1LwnQHmJ+7tqFq/E8YOQWVQ3KAjUSv5oujFEp9lT05gWUlgor77UIS2d9YOHtX9BVHh8DmAhaL+ESw3A5t5Dzea2oRGXfchL8VI+SWbGdQLDTguFcny3LGDFNNfFkGi9LUxw7Ysw/dj68g13IiCx+FVcGL/taK/iwCfNUojXmcApz10cZUSmusa3PA4aaGrRCIMlcu88I1bKdyQ06ab6mTGnhu99U3hiuP7KxxH618FVcpFKJQ0wZ68O58fcdrQXwyGhpaP8EL25b/84ATKF8CnvUE2KRK1/QcJVYQ== 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 Received: from DM4PR11MB5994.namprd11.prod.outlook.com (2603:10b6:8:5d::20) by CO6PR11MB5587.namprd11.prod.outlook.com (2603:10b6:303:139::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.17; Fri, 23 Sep 2022 00:46:13 +0000 Received: from DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::16d:109c:ee90:fc9d]) by DM4PR11MB5994.namprd11.prod.outlook.com ([fe80::16d:109c:ee90:fc9d%2]) with mapi id 15.20.5632.021; Fri, 23 Sep 2022 00:46:13 +0000 From: "Zhang, Qi Z" To: "Liu, KevinX" , "dev@dpdk.org" CC: "Yang, Qiming" , "Yang, SteveX" , "Xing, Beilei" , "Wu, Jingjing" Subject: RE: [PATCH 1/2] net/iavf: check illegal packets Thread-Topic: [PATCH 1/2] net/iavf: check illegal packets Thread-Index: AQHYzlLg+IYtI5FJQUG4F/vo+xi0Qq3sLumg Date: Fri, 23 Sep 2022 00:46:13 +0000 Message-ID: References: <20220922070426.788643-1-kevinx.liu@intel.com> <20220922070426.788643-2-kevinx.liu@intel.com> In-Reply-To: <20220922070426.788643-2-kevinx.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.500.17 dlp-product: dlpe-windows authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR11MB5994:EE_|CO6PR11MB5587:EE_ x-ms-office365-filtering-correlation-id: d509d098-028c-42a9-3ade-08da9cfd03c6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KcUWOMOivDfrrHGzpCkSpmdwp/xnTt2ZOhQ1SscvvaOIc25xpDmGe/bVhIBHaP+bsIU6IbQj7i0+h5ep4KeTNxm6Q7wOpLkqkIOlR4Cmw3P4j2B9InJL8FD5OxDIKjiHpdtXzcesCCnpZ8fi5wDu8iouKpOkexKJ8BfMRyMOOLfqkbvKNYm8vivhKDNwQqaYbJ4Z7UvhLOdewuloA0FEZ309aAz53J6nAyBPBSnfBFhZkUsjeRcBfVxKI3eIvu6b++9C2uxAaf/nK9P+SKsCNxjob3S2u7v9Rw0Nz1nTY2UfUlnXLorPcPxU8lG4PJg5log6IjEhAz8T7EzlIGkBn7xoKIXT7mmMhIKDZYhzuKicQhk0+bK0uHg3CEppjCvxx6M5FoAFp+1jrb1sHmJWqheNsPNk3+6dNkoJIzsQ86n3lKUFCIHzzqhMXuwTopu6mnh3j/G+I0lskFO8XAtwUleAS+ur/OFDyvpQe6B/twKYBcJQtGvjzp4W9M/IP1Z+WDaoCmH6WAnbkrWu+2ZXL2+0ZgDcSY6C0QnKmrY0uEfxFiY7ga5hcz88n0IbnStVnosCE/zMpv5LJX6hI0/wrqSPp5DL5J4Ot7qwTs+BoJcJ9LrCX2yTPqinBTTxtvfWFi5diMvdeS5b1YWuT6gnhlJaPJlCdXp1x0ffiGP2C5ii/HfRE5w5bZYW/+/sYnW/vm3R0KNWKxCxwf6HgZ9P3lwhJ1wUKVUv0z+/bCmg/HUyRH0s2TddbI8zsY+LYqOymE3MoGLHoAAunepyfSCrGQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5994.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(376002)(396003)(39860400002)(136003)(366004)(346002)(451199015)(54906003)(2906002)(110136005)(76116006)(66946007)(52536014)(8936002)(316002)(66556008)(66446008)(8676002)(66476007)(33656002)(64756008)(4326008)(71200400001)(5660300002)(41300700001)(86362001)(478600001)(53546011)(7696005)(186003)(83380400001)(6506007)(107886003)(38070700005)(26005)(38100700002)(122000001)(55016003)(9686003)(82960400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?NGhNuHCOWTVpyZVIwFLw6LQJnVlfcUbgDSm3j6G4RjNZWAVnqSr7Zfzj1RN8?= =?us-ascii?Q?92G2DRkzCbxETBUoibw2EtKjvgTlyhhJGyCK+ax1KyW3mcMEEtmGxmZmb3j/?= =?us-ascii?Q?r8S2nCwJhWcQa4UHNR0s1mVA5nZ842JFeQ2GclY4XlxAI9bGvnIHE6U9rux5?= =?us-ascii?Q?t0BnX55uhF6HyqHzfWg9vBlR5xwNdCFpUjJ5S37ZbhNo3MAvECFAheNqcBFs?= =?us-ascii?Q?25RyHn6lLbk9AGNND6rRg6OdRbb3ZeNDeW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C3M8/vysqfPMnUPhYxAuTpxmpcx53+Uwwv0/QwZtDU0g/4kju2J?= =?us-ascii?Q?fc0JPicdKw/DvUAHOtG0PcBl3GPAM2+1yzUCogjvNewIt/78MNUOmUUfwVd4?= =?us-ascii?Q?DUQqezyVS2oiGC3byEbqsYgnb+Y4U4Xi539Gakhj2H4kHOup9wGJn9VTnhvW?= =?us-ascii?Q?VRLAwSJVcEX/F/79untchKfmq48keVQPcgfZamIEGBMir9xLxY9dypJLVYc3?= =?us-ascii?Q?pos8YC3bxEjHxXIZVJyQ1jZOdOT2L2kaYTjXzOaOg3/fBkCHHpYnCBmUMkWB?= =?us-ascii?Q?okMaDzsFwGzjOYmWMDSyvU4bLQhKmjPPc8BoZv0H5hG+B9LOGHidsczbJlRI?= =?us-ascii?Q?KjGDG9AJzrPN+XKlV2iS2n95T7uvhZ3oxDZ5LXCDF1wS/ObDfydAA2qPsonZ?= =?us-ascii?Q?QWSc8+EPu+XsFav3suXUHtBwKn7AjRCBZPIfsGPB?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5994.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d509d098-028c-42a9-3ade-08da9cfd03c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Sep 2022 00:46:13.0172 (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: jL5PNspKhrDnhR21qU3AjfAWVS1jX3Tav2Bhv/BW7w0Ivto/aySenNqBcjpZQVU4oVf5eamuunyv4VF2HWiF8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR11MB5587 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 > -----Original Message----- > From: Liu, KevinX > Sent: Thursday, September 22, 2022 3:04 PM > To: dev@dpdk.org > Cc: Yang, Qiming ; Zhang, Qi Z > ; Yang, SteveX ; Xing, Beile= i > ; Wu, Jingjing ; Liu, Kevin= X > > Subject: [PATCH 1/2] net/iavf: check illegal packets >=20 > Some illegal packets will lead to TX/RX hang and can't recover automatica= lly. > This patch check those illegal packets and protect TX/RX from hanging. Better to describe precisely what kind of illegal packets you are going to = prevent. >=20 > Fixes: a2b29a7733ef ("net/avf: enable basic Rx Tx") > Signed-off-by: Kevin Liu > --- > drivers/net/iavf/iavf_rxtx.c | 10 +++++++++- drivers/net/iavf/iavf_rxtx= .h | 2 > ++ > 2 files changed, 11 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c = index > 3deabe1d7e..8ddd809f94 100644 > --- a/drivers/net/iavf/iavf_rxtx.c > +++ b/drivers/net/iavf/iavf_rxtx.c > @@ -2877,7 +2877,8 @@ iavf_prep_pkts(__rte_unused void *tx_queue, > struct rte_mbuf **tx_pkts, >=20 > /* Check condition for nb_segs > IAVF_TX_MAX_MTU_SEG. > */ > if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) { > - if (m->nb_segs > IAVF_TX_MAX_MTU_SEG) { > + if (m->nb_segs > IAVF_TX_MAX_MTU_SEG || > + m->pkt_len > IAVF_FRAME_SIZE_MAX) { > rte_errno =3D EINVAL; > return i; > } > @@ -2893,6 +2894,13 @@ iavf_prep_pkts(__rte_unused void *tx_queue, > struct rte_mbuf **tx_pkts, > return i; > } >=20 > + /* check the size of packet */ > + if (m->pkt_len < IAVF_TX_MIN_PKT_LEN) { > + rte_errno =3D EINVAL; > + PMD_DRV_LOG(ERR, "INVALID mbuf: bad > pkt_len=3D[%hu]", m->pkt_len); > + return i; > + } > + > #ifdef RTE_ETHDEV_DEBUG_TX > ret =3D rte_validate_tx_offload(m); > if (ret !=3D 0) { > diff --git a/drivers/net/iavf/iavf_rxtx.h b/drivers/net/iavf/iavf_rxtx.h = index > 1695e43cd5..bb9083c699 100644 > --- a/drivers/net/iavf/iavf_rxtx.h > +++ b/drivers/net/iavf/iavf_rxtx.h > @@ -53,6 +53,8 @@ > #define IAVF_TSO_MAX_SEG UINT8_MAX > #define IAVF_TX_MAX_MTU_SEG 8 >=20 > +#define IAVF_TX_MIN_PKT_LEN 17 > + > #define IAVF_TX_CKSUM_OFFLOAD_MASK ( \ > RTE_MBUF_F_TX_IP_CKSUM | \ > RTE_MBUF_F_TX_L4_MASK | \ > -- > 2.25.1