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 2E038A00C4; Thu, 29 Sep 2022 10:33:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F3C340E5A; Thu, 29 Sep 2022 10:33:57 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id C69ED40694; Thu, 29 Sep 2022 10:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664440435; x=1695976435; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=JmcVSvmFa6NsOReaDB1t9M6Jksx1//xY7WRfGXjxLMM=; b=h1dlL4yLfXXYk1RERXm4pmL2wNCbwXtQCXGoUJ7VbtgibzyxVy+1ciBO wcgGzZdihNAU447zD54qsGwbk3p7Wxcw5ll9BnuMGXGgQbd2YPbaFuVe9 ITlXk/b+g5VvHiokuw/9eSz0BJckXYdWmEAt5I/GeuWOUDPL2W1NIUKkX zPZNgBcr3HO0H0O1BH4hH6e4Px2gJ8HNQ2cgOHKu5Qaaz2TbgTXwWfRq1 k8zApxqhSAam9LtJEF2xFYaGK1NEV6qXTtleKeV7foehTpJM14CwJ35Xn MHwF/x7b7U3RaGqoTaGfRGg0zgKaBF5Ie2Au4GEdBQ/3Pmg2du1Ba5da6 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="363676511" X-IronPort-AV: E=Sophos;i="5.93,354,1654585200"; d="scan'208";a="363676511" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 01:33:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="747747360" X-IronPort-AV: E=Sophos;i="5.93,354,1654585200"; d="scan'208";a="747747360" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP; 29 Sep 2022 01:33:53 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) 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, 29 Sep 2022 01:33:53 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx608.amr.corp.intel.com (10.18.126.88) 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, 29 Sep 2022 01:33:53 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.47) 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.2375.31; Thu, 29 Sep 2022 01:33:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KQITgGjUWvOpg7Fs9MDLylwnjfodPRUUr4rOhpt9jMUp57iYOFgbwH0nlf4U7ly4ufyeRM2Pc2b6IwhDtI+W2efgEZDIAkLyq0vGYJqhb9OI3yNo6MSY+kltFyK3xK7HEXOJnHnWKnWRF8z0hZKOF7+GNxjqz9UnZMgybw7Bmx3EjacirAOw+LAvmldFfnRtxwiEXrtZ1RHFHmAF10NVNqYcR2l87fBrRH3o1vXt8WlCV0mZvNWGu5eKutcCoxgsV+zI7Pg0mwvjjbrySseau+sd59KS+ng6YUw+UxFfeQglT/PVPNvKf9kUoEXS/5ifLSTdCQ/VnKdPqLlbutv3Mw== 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=xWVayOxHdx101D8nkrwgFbu/ZRVaRW1gSVfIPYuwBJw=; b=WtaWuL9Fvo+DX/aJakdvR9qwZdBR+F3m2dbQQwL13818ZsJbJ2SsKSowOPmH/i/cuUPmNlKdoyL21Rnxik8krufa5+/V3ITCBaPQs4mZTJvJ5effCmzY6tlEpV68dXOx9E7dZ7JJuYZeT57l42OezlrIVSKmG8FyHKXMHmscxBf3a45jhV/b8/LzggvCPWxIYLJ0KElLtWxy68CRJPzsLkoFTM3QYKmO7vdMo04tBOXDE+OZbNyeNhEmQCYAvvMSCx8v3BCPCDcGjoTPbS0JWJ9aar6Ix4iUpgVwqI7/UUT/aNh5xWbCsZfKUKSrSyeQdo89ufLxC8HxJAMBWQxYMg== 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 SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by DS0PR11MB7286.namprd11.prod.outlook.com (2603:10b6:8:13c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Thu, 29 Sep 2022 08:33:46 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::39bf:57b1:4824:d40d]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::39bf:57b1:4824:d40d%6]) with mapi id 15.20.5676.017; Thu, 29 Sep 2022 08:33:46 +0000 From: "Xia, Chenbo" To: Alexander Chernavin , "maxime.coquelin@redhat.com" CC: "dev@dpdk.org" , "stable@dpdk.org" Subject: RE: [PATCH v3] net/virtio: fix crash when dev is configured twice Thread-Topic: [PATCH v3] net/virtio: fix crash when dev is configured twice Thread-Index: AQHY0loMDR3D6TZyG0G5mbw04FKj7a30RfaQgAHRmsA= Date: Thu, 29 Sep 2022 08:33:45 +0000 Message-ID: References: <20220926083212.1178663-1-achernavin@netgate.com> <20220927101504.1220037-1-achernavin@netgate.com> In-Reply-To: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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: SN6PR11MB3504:EE_|DS0PR11MB7286:EE_ x-ms-office365-filtering-correlation-id: a6c9c3c6-78dd-4f41-53fb-08daa1f55326 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: taedWxfZ0NIfo0BFt7LdG1Hidf9u12w6Kf511ZX1RQrRd2Xgd5x5UlCqxwcRDNh8XlVr56jZEA9ZD5Wlea849YGtJy64sao1gkG7XqO9rzxTm4PxZiwrxI05lBGXaGPH4wEdJ0iFhzkIWHob4XWowhWRO2KcOPg+MuBAq8UfKJk4JK9pJ7ggbuc6uMVNCXi4z/hdS6mXFFEyo2e905iQO3CbxHWEzdw1VjKy4luglie4e4W4s/nb3Hq3jqXYoECxWM2a3YWyKAqnAeZjLpwvvuMoBqpKu+Zip+8vt1XEYj8MZOqHuP9dTNuTAqHyjfewUJxMKLPwkSBG+WWlMgqit3y4fCqH6suNfre6y05Yc8SW2+e4EUgCN+2tARkaJnRGvGIc326MrDjXrHpwcje8MZ3kXYwNINdpIRyU5aL8EiJ/BZdHEGeMizYEjhOnKnR9i20/HkTAlL0EA84mQMz1HGTStg8atZ/7SXCqwB+Tf0C4AR6R1k8d6xsjAkHToZ+c9K6MM0z/Ujnkq75TmgOMvt2+/o5ThA+DAOb8DO/7HrQjRd2i7PpW3MFEAM2rt26icU6rztU52V4zdtmt2veQs3+oEUwflIHPMWLoGvBwKc0ez27k9KLbOGzLOmHwlT3Oy8f9Izlmbolbb1UE39t6c34mcqtnB5O79JTG9qkAVxFsLZjxFqVkO136ZSyZYeFQtk65g5xkYwM9m/kSSeLzLoHjDxXAl0IulPxYlu+wXkLtA8o/cyat1kUeyo8LXrSbtUgDdl51vmbsFp9pxYSohg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(396003)(136003)(39860400002)(346002)(366004)(376002)(451199015)(86362001)(38100700002)(82960400001)(33656002)(122000001)(38070700005)(186003)(5660300002)(55016003)(6506007)(71200400001)(26005)(53546011)(478600001)(9686003)(41300700001)(7696005)(8676002)(83380400001)(66476007)(2906002)(4326008)(66446008)(316002)(66946007)(54906003)(64756008)(110136005)(76116006)(8936002)(52536014)(66556008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?MJf5O0bAH9qxP/mFdW5ir2K9c5LWPwB743WLEmx77heZT+WScIUBE83djezZ?= =?us-ascii?Q?2Yeu+Ns8ZrZlf0ai/dkrl2SysBUdhkXCM7J+2Vq9wkiA2ESL7VK01RJI//FJ?= =?us-ascii?Q?3qy+G7ckVp56rBh5hVwrmQ8MHwihPZ0E86tNH/0Idkf5SJVvwdlasOoNV/Lc?= =?us-ascii?Q?nWibaCnRXhhHc7zzmZ/QOK9u/a9QmB42sRipflqB1rahYI2nalyp8k/mozg2?= =?us-ascii?Q?dssd8zxjgtlcO3Q7akecqWyQ4rp0qoZhLj2YNj8feFOfj377XYMPNg5/IsGB?= =?us-ascii?Q?YuivP+HAamqa61VPcCA/5IKMN9uB9P2wqPn7yWG2rgmDWamPrvXl9zSUYueZ?= =?us-ascii?Q?XlJTIB3Ba36HUodtS21LWyxd0NKHZAhEqcdFDaFUMPdhl0m5QPDGW0UspeXM?= =?us-ascii?Q?eJQ8zwHamN72LS05ZTTRkb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ad9Vv3?= =?us-ascii?Q?hrlXl2iEv08KW76N74KoYljNwFH8QyL3NRZknMcbaAuyVrHbERjXsbhCT2p6?= =?us-ascii?Q?HztUwT40DrdicCgHjl2IA2ynn6XXARtvMi6KpcquM47Gsl3bmgxQi2W2s92y?= =?us-ascii?Q?E2yGOeBpzxcyAk+HSOM0kZahyho1sAuohvOA1h6dd9X2IRMBLb+5aN+v+mNM?= =?us-ascii?Q?u8AFvgZezqWAbNK4JukRSSx8CFIv3LXmAH//RjA8NRTDkRHFnnPRAb+sE3x9?= =?us-ascii?Q?lcMg0xioNQhqTmnURklU9HLnGUu5t5afYD2PfOQD?= 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: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6c9c3c6-78dd-4f41-53fb-08daa1f55326 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Sep 2022 08:33:46.0114 (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: U+99ytHrYB5/Pz2CZ7sQWDu/Rl5ehHfQmUr8j+Qdxl0O1Biva4KTAMPyV/KME+FchVox8+JgIQVyTQysLd0geg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7286 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: Xia, Chenbo > Sent: Wednesday, September 28, 2022 12:47 PM > To: Alexander Chernavin ; > maxime.coquelin@redhat.com > Cc: dev@dpdk.org; stable@dpdk.org > Subject: RE: [PATCH v3] net/virtio: fix crash when dev is configured twic= e >=20 > > -----Original Message----- > > From: Alexander Chernavin > > Sent: Tuesday, September 27, 2022 6:15 PM > > To: Xia, Chenbo ; maxime.coquelin@redhat.com > > Cc: dev@dpdk.org; Alexander Chernavin ; > > stable@dpdk.org > > Subject: [PATCH v3] net/virtio: fix crash when dev is configured twice > > > > When first attempt to configure a device with RX interrupt enabled fail= s > > for some reason (e.g. because "Multiple intr vector not supported"), > > second attempt to configure the device with RX interrupt disabled and > > feature set unchanged will succeed but will leave virtio queues not > > allocated. Accessing the queues will cause a segfault. > > > > First attempt: > > - virtio_dev_configure() > > - virtio_init_device() is called to reinit the device because > > "dev->data->dev_conf.intr_conf.rxq" is "1" > > - virtio_configure_intr() fails and returns an error > > - virtio_free_queues() frees previously allocated virtio queues > > - virtio_init_device() fails and returns an error > > - virtio_dev_configure() fails and returns an error > > > > Second attempt: > > - virtio_dev_configure() > > - This time virtio_init_device() is not called, virtio queues > > are not allocated > > > > With this fix, reinit the device during configuration if virtio queues > > are not allocated. > > > > Fixes: 2b38151f745a ("net/virtio: fix queue memory leak on error") > > Cc: stable@dpdk.org > > > > Signed-off-by: Alexander Chernavin > > --- > > v2: Add Cc: stable@dpdk.org > > v3: Add Fixes: 2b38151f745a > > > > drivers/net/virtio/virtio_ethdev.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/drivers/net/virtio/virtio_ethdev.c > > b/drivers/net/virtio/virtio_ethdev.c > > index d180162abd..38bfe050b5 100644 > > --- a/drivers/net/virtio/virtio_ethdev.c > > +++ b/drivers/net/virtio/virtio_ethdev.c > > @@ -2616,6 +2616,13 @@ virtio_dev_configure(struct rte_eth_dev *dev) > > return ret; > > } > > > > + /* if queues are not allocated, reinit the device */ > > + if (hw->vqs =3D=3D NULL) { > > + ret =3D virtio_init_device(dev, hw->req_guest_features); > > + if (ret < 0) > > + return ret; > > + } > > + > > if ((rxmode->mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) && > > !virtio_with_feature(hw, VIRTIO_NET_F_RSS)) { > > PMD_DRV_LOG(ERR, "RSS support requested but not supported by > > the device"); > > -- > > 2.25.1 >=20 > Reviewed-by: Chenbo Xia Applied to next-virtio/main, thanks