From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas.monjalon@6wind.com>
Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50])
 by dpdk.org (Postfix) with ESMTP id B2A36108F
 for <dev@dpdk.org>; Wed, 25 Jan 2017 12:56:09 +0100 (CET)
Received: by mail-wm0-f50.google.com with SMTP id c85so22681119wmi.1
 for <dev@dpdk.org>; Wed, 25 Jan 2017 03:56:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=6wind-com.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:user-agent:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=eX0088ae0ITpgBXEbkmqjTDBwyJ+hJgQe6DyircX/FQ=;
 b=hMOJhz/qvhMisDhCV1fqoswMTeHsY85Kd0vcnWh7hcJcUAgp+OFUu7qyJZWA42TXle
 lTOyl/AtSq1ty3zfVG7NM7aZApHllNcoV1NNmUPviMcJzDVoAxjrhioRuYmyTEroLkl0
 vK9jEJ16OlndrevbnUTqfzqkKwoGvVbpgj0ce2nZyuh6nnTOAhikuX7gpuIg3uaUNBQb
 0e5WTV2Ykq19pMg8fX8XSvzy7X31FeSANMADvxyFeZEQCkzfb6CLdnfoYqkHq53+dXn+
 8CsG6SzFEila+N4rRPFenWEf7JCrI6/WNgvRhUo99Xk/3PJFawMJ1YlBDPulAkyIoBi9
 mefw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent
 :in-reply-to:references:mime-version:content-transfer-encoding;
 bh=eX0088ae0ITpgBXEbkmqjTDBwyJ+hJgQe6DyircX/FQ=;
 b=HhxLa7bzp04z1kUyRz9EvpEiu41FMQsZyNQAZXCyM8+c83e4DktH6jiG4dpbEImFLJ
 Hz+x6WpQ2iL5JCRfD8jo8LMHCAtAL+p6UCJkJ9VLDvbiqEQBJtZYHl8mU2R37742tS5R
 WbY+m/wYWLUfMtnj6eozk00mkXz0GmilULCPCzjwRHxrsTiGFdWKw+XjdDQc5TdlPzp4
 q2YdFHistvWyoaKz42OzCAjzKYttuXrK2i34LlrWFalu27D6HcIysSwpfzgBYb9XKtx6
 pDVCoFDHlEAEmuLtzvpfHENH8wLzWajCTlw7cVIbdq+YOwgJl7/lzfFU3AgKJpFNq1Hg
 CulQ==
X-Gm-Message-State: AIkVDXJQD3sC3JY2cZyX9RciW2b0iHljW/hivAQeF62LmBcQPEyJlCvxwceki14hldaOUlo1
X-Received: by 10.223.143.48 with SMTP id p45mr32827841wrb.33.1485345369382;
 Wed, 25 Jan 2017 03:56:09 -0800 (PST)
Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184])
 by smtp.gmail.com with ESMTPSA id z67sm24655899wrb.49.2017.01.25.03.56.08
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 25 Jan 2017 03:56:08 -0800 (PST)
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: Remy Horton <remy.horton@intel.com>
Cc: dev@dpdk.org
Date: Wed, 25 Jan 2017 12:56:07 +0100
Message-ID: <1844096.VBZFUxdXJL@xps13>
User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; )
In-Reply-To: <1485270071-5407-1-git-send-email-remy.horton@intel.com>
References: <1485270071-5407-1-git-send-email-remy.horton@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Subject: Re: [dpdk-dev] [PATCH v2] ethdev: fix multi-process NULL
	dereference crashes
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 25 Jan 2017 11:56:09 -0000

2017-01-24 15:01, Remy Horton:
> Secondary processes were blanket zeroing ethernet device memory,
> resulting in NULL dereference crashes in multi-process setups.
> 
> Fixes: 7f95f78a8aea ("ethdev: clear data when allocating device")
> 
> Signed-off-by: Remy Horton <remy.horton@intel.com>
> ---
>  doc/guides/rel_notes/release_17_02.rst | 5 +++++
>  lib/librte_ether/rte_ethdev.c          | 4 +++-
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/guides/rel_notes/release_17_02.rst b/doc/guides/rel_notes/release_17_02.rst
> index 0ecd720..1472f84 100644
> --- a/doc/guides/rel_notes/release_17_02.rst
> +++ b/doc/guides/rel_notes/release_17_02.rst
> @@ -222,6 +222,11 @@ Drivers
>    Fixed few regressions introduced in recent releases that break the virtio
>    multiple process support.
>  
> +* **ethdev: Fixed crash with multi-processing.**
> +
> +  Secondary processes were blanket zeroing ethernet device memory,
> +  resulting in NULL dereference crashes in multi-process setups.

It does not describe exactly the use-case it is fixing (same in commit message).
I guess you saw an issue when creating a vdev in the primary process and
another one in a secondary process, erasing the data of the first one.

nit: ethdev bug should be shown before PMD bugs like virtio one above.

> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -225,8 +225,10 @@ rte_eth_dev_allocate(const char *name)
>  		return NULL;
>  	}
>  
> -	memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data));
>  	eth_dev = eth_dev_get(port_id);
> +	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> +		memset(&rte_eth_dev_data[port_id], 0,
> +			sizeof(struct rte_eth_dev_data));

My previous proposal was:
	memset(eth_dev->data, 0, sizeof(*eth_dev->data))
It is better to avoid reference to the global array rte_eth_dev_data.

Anyway, the shared data are still overwritten for the name, the port id
and the MTU.
Please describe the exact case where it is working for you.