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 69653455FE for ; Thu, 11 Jul 2024 18:11:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6396942E60; Thu, 11 Jul 2024 18:11:09 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by mails.dpdk.org (Postfix) with ESMTP id DEF2E410F2; Thu, 11 Jul 2024 18:11:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720714268; x=1752250268; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=6VyVbJ2kea0tPClE0++HnkQ8LCgT2SdrIdHhHjYebPE=; b=f5kLliOONIV0iRZgeW7ACLgKheOcM0GzcAz2M7YrP2gtwdnh3+G5wEby 178TABigQ6hEscnAz3kCt3+6nKGO7yfeCCPuhLvREvEihD4y41G87a1tT kopOA4JaJjDeArFf9nykAAiU9c5AvP908WfL4xyZPn6yWNBbKRXcvfguw oYmvU0to/TOrXoBnyU1sNjUDNFJoWVvEGV1164sdvC9FUg3moz0K2axko rNLKf1BL0qdHovxOs7uBqTObadjBSQIgeESsaEPuX5CfQ0cxiTMgETofJ KIQCwhVhnLdaKa0HTJCPaAM5Y7Jck/jqZuKis53z/cXx7C7McliI0l9sm Q==; X-CSE-ConnectionGUID: 1jvZqwqmSkqAUtyI91Fv4w== X-CSE-MsgGUID: Uhhvod0ZR9Sf/tjIWV2kYA== X-IronPort-AV: E=McAfee;i="6700,10204,11130"; a="17954886" X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="17954886" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2024 09:10:46 -0700 X-CSE-ConnectionGUID: dBEfSJe6RsWAo534Luju4A== X-CSE-MsgGUID: yKTkgo9cRQmMCnEMs5Akkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,200,1716274800"; d="scan'208";a="71810009" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmviesa002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Jul 2024 09:10:46 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 11 Jul 2024 09:10:45 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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; Thu, 11 Jul 2024 09:10:44 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 11 Jul 2024 09:10:44 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.44) 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; Thu, 11 Jul 2024 09:10:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pkk/mlEBYuh5SoY/tPTXblVILUaAZhka+nduU4kUvP6Zo5ojHHMHuO2DMGrGjdbwvU09BdJefs6eN3Uk1BAB+qABDlUsJ41/FyCxg6WVl/yuAqUn+neEAizGIItzrrYmQQ5Tfl1nrdgSeRqTYu9C1mCEq3HKWFALJP46CkiqHne3MTfn2YfZOyt6sOFygWEZlnkjvy4jEZquKlAWWlhk0s69fP7n6jdqKPTw1XcHeVw6uGWyr2nlZ/wbqA2jEgfi/JLPLOvcy2/To76qkar3aCbHJwI4+KFXBU38/XaCQhVF1r8SnO+lD+LOJ4mUfQAWjbtRHFU4CJ4nvLh0PxUa/g== 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=k6bDhBeZIR70wxMDVvALUeDhCAxa2wAlLVoHb8uzgsQ=; b=qQzS4l/Itxo55TSLZVi5QnuI0Jw0XfHnM5+kR5WWW7vI4TGRX70+YMmy5BrbuiTmtTTs6X8aM4xrk+udbB5jTf3jBYlY0m4NtdIg4OuN0MCFOR33SlfcFyA9iaO+NvSArYsp563gDuHWPzJ8IVC6oXBEqoXS5o3AYa8ZQlkPSS5zFuO367iCMeljG+IyxsW1Z2k+da0UckIU2bJ5KE03EB20ebN+B20R2KBFQwMbIKAlvbscDQ3dbJRfMMMsLuhybWcWMGf/wIap3j8Eg1pL9fQ/Wluavi4605gm1TNaRgyZjJWdN57pxuXYj+bGEUGF0AQEnrniTTYjkPGQnovTLw== 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 DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) by CY5PR11MB6161.namprd11.prod.outlook.com (2603:10b6:930:2a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.34; Thu, 11 Jul 2024 16:10:36 +0000 Received: from DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::21e4:2d98:c498:2d7a]) by DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::21e4:2d98:c498:2d7a%6]) with mapi id 15.20.7741.033; Thu, 11 Jul 2024 16:10:36 +0000 Message-ID: <48edd8b1-715e-4363-b627-37a910d2dd70@intel.com> Date: Thu, 11 Jul 2024 18:10:28 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/3] net/vdev: fix insert vdev core dump To: Mingjin Ye , CC: References: <20240314093630.1066948-1-mingjinx.ye@intel.com> <20240314093630.1066948-4-mingjinx.ye@intel.com> Content-Language: en-US From: "Burakov, Anatoly" In-Reply-To: <20240314093630.1066948-4-mingjinx.ye@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DU6P191CA0014.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:540::15) To DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB6502:EE_|CY5PR11MB6161:EE_ X-MS-Office365-Filtering-Correlation-Id: eb613db4-d56c-4d2e-bbbd-08dca1c3ffee 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: =?utf-8?B?Z1RuZzN4MWxqVlRFUWNUaW1IN3dabnh2M1ZvSlRLRzJodnJpblNTbHdudUJ1?= =?utf-8?B?eGJlTEhuaWpYbUNaWHBQaU9TSmJzMTVIZGEySVRVWXI1ck5yTTBBcUJVb01W?= =?utf-8?B?OU9Xc0xkWmJrVmp2aGNKSUhYTjE0NXNKUGt4VU05YnZsSCtNaytzYmI1dGV0?= =?utf-8?B?Z0xLb3pBS2NhTEkwUDB3UDR2cE14Q0ZpOU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ZqWDhWbitXdUhyaTFQSW85ZWRSc3k0Z2pXU0JPNi9iRytVSzhW?= =?utf-8?B?OHU0N3AzRURxWm5tWDJQaFZ3dzlTMWM0WU4xM0FhcHRPWG4vQ29MNStQd3h1?= =?utf-8?B?cFdqZHowTHhIWS81UFRJWjF4cEtqWWZKTGJSR2hZRTdzRzlheE51NWxQOEJi?= =?utf-8?B?TWVUMjF3U3pDcStNOEpTWjVaWjZiVFB4eFpLVUxEUC9tS2lYMnE5SDVlZEZj?= =?utf-8?B?MXZCSGxUNmxXWVBBeVRJL0ZHZ1FtM1RKc2NXeWZmVmlSYlZranhZb0Voc1Zm?= =?utf-8?B?MUh1Rk5FSVpjaVlsNFNObVdORUpjMk5admk2RXdqWklHT0EybkN6cmx3cjdl?= =?utf-8?B?UUt6VGJSb3hzbGFhL1NKU0NkNnMwemdnSzFsV3pvdmtyZ1U2S1JGeFlwcVRI?= =?utf-8?B?NVgzS2ptQ3VoVTRsSmtOUGhURlVFSzlZME9vQ3JLbVRRNnY4c0dXWE4xSnIy?= =?utf-8?B?bmkwTnpJeS80dWtJY2NSZzlZUHNRVXlRazhmZUZvY0lWdDdoSVdtd3YvWW9X?= =?utf-8?B?NGw0WjZyUUd4Qklnamw5VmVzNVVwMWFrWVVRWm43dzVqeHZjZThkN05SVVVF?= =?utf-8?B?dktnZXRqNTU0WS9DWmV0SDZiZmV1ZUdlVVBOSEIySHl4bzV4dTFLL05rdzJR?= =?utf-8?B?YWE4NjBVQVF6RlhZcFk2bXZSWU9rdmE4aEZQMjVlYS9lVEsvOUY1S3VCcy9N?= =?utf-8?B?L2VOaGdGQW1HMlVlTU1pQT09?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB6502.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1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VYWGNYd3VOdHloNnhlVWs1R2hrcENET1FxbFZTR0wzQnBoT2dQWFpuaDN4?= =?utf-8?B?L09SK2RYZktpZ2Y5TmtxYUR3Z3VyNmpYc21VTmpvZWNjU2FxcndvVmR5L1dF?= =?utf-8?B?YlhoTkZuOGN5MWZ4REF0SUVvSDV6VDBWYllqTTVlczFpMkdhM0VtdFNVbEFa?= =?utf-8?B?TWQ0MW1uVm1XaFErdXh0dE1LWFlrd0JLRiszbE9WeGM5SnVPMi9WOGdCU1pK?= =?utf-8?B?V0NFYmtpcVpKeVZjeU1LS1NJOW9pcXVmQXpWVThSd0ZBRnRudGlkWTlrYjJi?= =?utf-8?B?UmRMMTZVTXV0THVvNWptL3NUQU5nai9ZalhRaXduZndsbkFOM1RsU1hSdTFp?= =?utf-8?B?d1NXSmhoc0czRzJMblc3MzkxRngwOUE1dXEwYjJ0Q2YwV2JrUGJrck9XNkE0?= =?utf-8?B?Snc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: eb613db4-d56c-4d2e-bbbd-08dca1c3ffee X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB6502.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2024 16:10:36.5585 (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: nCgQP/kf1C2S2aXkIBFwebzDMV39TVAxX0/hJkc9HuOVHDFAcWwIcGyE3KbWSkk7Btu0EouYJ8Q/JDDK6H8yWkqTRzeS/8xMn10nfIxqG14= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6161 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 On 3/14/2024 10:36 AM, Mingjin Ye wrote: > Inserting a vdev device when the device arguments are already stored > in devargs_list, the rte_devargs_insert function replaces the supplied > new devargs with the found devargs and frees the new devargs. As a > result, the use of free devargs results in a core dump. > > This patch fixes the issue by using valid devargs. > > Fixes: f3a1188cee4a ("devargs: make device representation generic") > Cc: stable@dpdk.org > > Signed-off-by: Mingjin Ye I am not too familiar with how devargs works, so I have a trivial question. I understand the point of this patch, and it is roughly as follows: 1) we enter insert_vdev and allocated new devargs structure (and copy the `name` into devargs) 2) we set dev->device.name to devargs->name 3) we insert devargs into the list using rte_devargs_insert 4) if devargs list already had devargs with the same name, our devargs is destroyed and replaced with devargs that is in the list 5) because of this, dev->device.name becomes invalid as that specific devargs has been freed - it points to name from the old devargs We do need to store devargs->name in dev->device.name, and we need to do so after calling rte_devargs_insert to avoid keeping reference to memory that was freed. So, provisionally, Reviewed-by: Anatoly Burakov My question is, under what circumstances would there be duplicate entries in devargs list? I assume there is an answer to that question because rte_devargs_insert() expects this case, so this is just for my understanding - I can't seem to figure out how we would arrive at a situation where we have duplicate devargs. > --- > drivers/bus/vdev/vdev.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c > index 1a6cc7d12d..53fc4a6e21 100644 > --- a/drivers/bus/vdev/vdev.c > +++ b/drivers/bus/vdev/vdev.c > @@ -286,7 +286,6 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) > > dev->device.bus = &rte_vdev_bus; > dev->device.numa_node = SOCKET_ID_ANY; > - dev->device.name = devargs->name; > > if (find_vdev(name)) { > /* > @@ -300,6 +299,7 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) > > rte_devargs_insert(&devargs); > dev->device.devargs = devargs; > + dev->device.name = devargs->name; > TAILQ_INSERT_TAIL(&vdev_device_list, dev, next); > > if (p_dev) -- Thanks, Anatoly