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 6C362A00C2 for ; Wed, 28 Sep 2022 06:47:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 918BF42686; Wed, 28 Sep 2022 06:47:11 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 0CBDF41133; Wed, 28 Sep 2022 06:47:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664340429; x=1695876429; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=fN1VUN/av971kh4dONUyNZvfDVzpoig87al1wG2iJNI=; b=beMP/NxaBZfF11PNnJ5nXmlpY5hYpGJPzidUKcMR3PacvKHardK0L8Gw usqtIoSZTTDerYoOt7sWgCVsjRmeb/1jhEe/SBdtqZayj5zz29hIaG9Wg qcnjKc62I+JdtlelblnGw7u7/b3C2qZYy8q44WRBiKcSaiN3E94BaJ3Mn TAWHkYAzNmgVOLKW8ng1gdVxgC/JamJZtaHiP74KoizmJ0i6XhVEEmNZx cbqHFA4QgSLRl+qzsE9Q1mqwic9WZSKv4wSmwb1Qt2Bm/RnXGvIqxCin1 yU3Tw+jA7uzbc+KhOJU1LFxTOcvTEVDrQajQ4KVsuTk3SxSVQVWNqIsAZ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="327867714" X-IronPort-AV: E=Sophos;i="5.93,351,1654585200"; d="scan'208";a="327867714" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 21:47:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="572894389" X-IronPort-AV: E=Sophos;i="5.93,351,1654585200"; d="scan'208";a="572894389" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga003.jf.intel.com with ESMTP; 27 Sep 2022 21:47:07 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) 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.2375.31; Tue, 27 Sep 2022 21:47:07 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 21:47:06 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 27 Sep 2022 21:47:06 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.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; Tue, 27 Sep 2022 21:47:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FbDHLooYNiwDocOVFV63/jfSib3/+qBg+gpnCn82GRQI34gc6S2HNtb0hyPGqe6Bx2pFqdDgZyMihBDiB4l2JQdSoIDpYr3bPVraBRDKwwOXHqtnm6vFmGWwLpavsdjAmXY7pOXFyaw40ErRo0oGvyCwdtTOm3ExrZShmZpgh0xDQojLIMCS1n5yezdjlvT2ILqDL044ysOw4Dm4MdD9UMxfAJwzLlvVuXz7TBmb25K/0A9fvdjyNVzYvmvs+fHWxQqNx4q48PuEejCUaX7wediGb8he6m9c13UXy5CFMBvE1CRyznfAV92h6ZlVvdi4hPmgYp49tSXw/TSBJWK0vQ== 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=3STLaTzbsYxjRSZQqImGqdutWuT9762gU45nyQ/lTBs=; b=QfDPy2FHr2XKGXfp1GvyEy6dAAh1IAaMxfwiHv7TfDjrt/2viCqD2B70H9splFpkuiG3T5Qclm5F+LxX9EZi894PzwzyKUB0tFzhAyRo3NYANfpcGWTHG4hDVjx+wrop40yh8P15Fvylz3WlxCGRA9WugK3A0kDvrtahcsvtrbiGmfkJ7Kz0iKvVp1oXZnjJoSxU6tW5aWU77sQ9AjQrLEUobEJSzyEcv2kVQJnToxlqdDRRFr3J3hWCousLCrayR02fZwJpUHUSxwxxU8V9PhHbg9XPCa3Ot3b8peNwqxNBwgzirxFXoxMLgFunshW9+gz9egpxMEbfSdlW9kZIpQ== 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 PH0PR11MB5577.namprd11.prod.outlook.com (2603:10b6:510:eb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24; Wed, 28 Sep 2022 04:47:05 +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; Wed, 28 Sep 2022 04:47:04 +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: AQHY0loMDR3D6TZyG0G5mbw04FKj7a30RfaQ Date: Wed, 28 Sep 2022 04:47:04 +0000 Message-ID: References: <20220926083212.1178663-1-achernavin@netgate.com> <20220927101504.1220037-1-achernavin@netgate.com> In-Reply-To: <20220927101504.1220037-1-achernavin@netgate.com> 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_|PH0PR11MB5577:EE_ x-ms-office365-filtering-correlation-id: a36d227e-1417-4d14-7c4b-08daa10c7d93 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 19nIEf4c8dXE7AvyRJa3BJMO7Yi9QZbtXp0tXSrGDFyd+0xltnhAwfPuVZeQJ3i8Tp3V86GMOXRbRdETCTSpeYR87QdqmaDLSj3B/B6EECpg6rNzVaxZaxzp1G8cN90OGWsSiyPccsDz4HO8L/cba3Nc5y97vl7OgwMrvRmKJrjatQDXhn2eMGW9WAuAHEScNoMpKru+jN2r1eIsh+uMyHZ0QceJ30zZd+tsgR3SKxig6OutfXCOjjzHbFJt9a7qkNoDftwQ8RNW8xlSJl8Z4QMs86jqqmIcDvLGdUr9euO/U4cOnfL9ov18ZcI2Byef3KcBLdjR3vzaCM4rSq0CkzFgWBjeEF5hIsBqLKMcx93J2ZNoGYJ+ZmJBitj4i3FbSB+IJt9OJklYRZbZmIXo/Lq3iGoGuS0FX9Z+4mIcNpH1IqrRxnNgEEgYPi7MfMIxiF7iPkFGdy7JqxGO3fo+kRAqCOs+jjDgvwZ+UN/GAZ/y2dn0xCZyg1ljFlYTMScTAcLJnuGAmOXiAKft3gLA4+imPUWGS1aZvG/201cEHRMbZiF4izjL6PqPiCdM7rdM9gesRNKgzaQ3cx4DBuI8oatrViElS8hXYO2ZSQRcHMl8uxQF/s3Y9wjuRI7n/RJJA/7h3oOF8wnvvQMZKl00eHDsZGZnh9sYSYuMAA+Pk/8iU1a8WEHsyR9yrHFvaLTlyu2rt8wtfHJ6uK+6n4pc4wjTfbe5HnVD3QjBQ62Dx+qsFcYueyuz8CjAqHJlRGB6O8DyRbFCcjZ8T6ywcHb0QQ== 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)(366004)(346002)(376002)(136003)(39860400002)(451199015)(110136005)(478600001)(52536014)(38100700002)(186003)(316002)(5660300002)(55016003)(41300700001)(54906003)(76116006)(83380400001)(66946007)(38070700005)(8676002)(66446008)(82960400001)(122000001)(4326008)(71200400001)(8936002)(64756008)(66556008)(86362001)(66476007)(33656002)(2906002)(53546011)(6506007)(26005)(9686003)(7696005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?dZ8fn9gWC4u47DviUXbXrrfN6X78rPISZs0D4CcbmfolIC3mMbM2KPp3fr+w?= =?us-ascii?Q?LbfoY8JB6ce1ViBN+ivgPgqCI4VJgQu0ik6e5JYtS8sjOyJZqnSd4ixIFObz?= =?us-ascii?Q?SaexnAazp3OyfkaBUTac4v7qhj55/E++y92lDQv5KWz/1grzoR9cUjboUOyT?= =?us-ascii?Q?gIEryVGi3oGhQZ+M/UamLVJM4v2td+7rfsjtln2W9tb7kdBpWTY45JGJKFxs?= =?us-ascii?Q?XsxFA3jHtkXS8g8f3Kk/MAisJ76+W+UFi/BOmA4hjHWo6/AmxWhPfibaG5mn?= =?us-asc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vLB4FcCyL3Q6OsfT5yzYYVJNylDLZt?= =?us-ascii?Q?BG+osYSaXpyVSksmR28NVDLICFFZ/ME415gJfC2va5kNkMCX5ythTxQJiSZS?= =?us-ascii?Q?gh+9rq6d5gVOfJzUdwcbitwGDH4wlGW1AZVhRzq5yTtv35PtBHYgrdCD+zFt?= =?us-ascii?Q?SNe8K4poV6IMssjk+J9p71DRS09F0x0s2B5fV8+6lEW20uPydy5UcEGoBijV?= =?us-ascii?Q?pq6/HOCYNk7dgmwRi0i1TLn2dojsjMrNhSeLGwOeMKo6yOE3GEEKqSLCW07Q?= =?us-ascii?Q?mbGfvBYsWJQuBfChvrAxrLzoCWHIqwOHNrZJZRDRd1KNHV/8fyfWMx5vS377?= =?us-ascii?Q?X+qB8EXZ5huofNIQleXZExpHOXVqpWcepGHcdchJaZBswWZp15nh2pvphKNG?= =?us-ascii?Q?7UU9/IDgce+d44TbEW1Y+wb6fZIxMkQd6w+Uzv2/?= 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: a36d227e-1417-4d14-7c4b-08daa10c7d93 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Sep 2022 04:47:04.4374 (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: 1t2UmwbsMGNkXS3x7ftKbwVSnxd4sJvMYsNpx86PbOcCT6SVsPgMUQqfB9YX7FEnSlzLnLI47kaYYHhlvCJyYg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5577 X-OriginatorOrg: intel.com 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 > -----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 >=20 > When first attempt to configure a device with RX interrupt enabled fails > 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. >=20 > 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 >=20 > Second attempt: > - virtio_dev_configure() > - This time virtio_init_device() is not called, virtio queues > are not allocated >=20 > With this fix, reinit the device during configuration if virtio queues > are not allocated. >=20 > Fixes: 2b38151f745a ("net/virtio: fix queue memory leak on error") > Cc: stable@dpdk.org >=20 > Signed-off-by: Alexander Chernavin > --- > v2: Add Cc: stable@dpdk.org > v3: Add Fixes: 2b38151f745a >=20 > drivers/net/virtio/virtio_ethdev.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > 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; > } >=20 > + /* 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 Reviewed-by: Chenbo Xia