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 C415A46BF1 for ; Wed, 23 Jul 2025 15:26:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B7A840B98; Wed, 23 Jul 2025 15:26:39 +0200 (CEST) Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by mails.dpdk.org (Postfix) with ESMTP id 20C7A40B98 for ; Wed, 23 Jul 2025 15:26:38 +0200 (CEST) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6fafd3cc8f9so83432406d6.3 for ; Wed, 23 Jul 2025 06:26:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uetpeshawar-edu-pk.20230601.gappssmtp.com; s=20230601; t=1753277197; x=1753881997; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0v8URUyvkobFqxxEJs0fTIJGVMqF1LM8Wzv1TSuE3yA=; b=UYb0dV1VRtULflVzW7g1tBXz934gs+TxOZg1An73HrY958dbacQZT/m9DbyhmSEqSB SGkeVA8B56G9WGx/MJ83H0n6ddSpM4uWgyhO8tzI9ds8YMV3CVR6ru9/33qyrSwRBVcS I+xZXBA63moIlpnrpM0wfHTAZZQXEAxESryyzx10nXxd5h7ijGwx5tk2Aj5+9MNLlxhz twdqD2/ztY8DHwSNqtWJL9pJL43mlE+2VKWvMyWpT4LEeC1asOyFQPX4QWR8rTu0HOv8 s2VkTxc3cYDE/q0PPeJXn/NpFjojKDk2TZQ+zdWKmIaIxbEJjU5c6u/jbeue+JHl8ITz jQMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753277197; x=1753881997; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0v8URUyvkobFqxxEJs0fTIJGVMqF1LM8Wzv1TSuE3yA=; b=IqAgmY7I0A+og1DzEsJ3nsUpKBNXqAooIXAcJgxsGKACDvX7AicSzduEK9BaPeIod1 Dpj2n6njjHmZJKoseVJVIcNr3TdF3Mz6qJR1DoUVuLYIfECKUu7fjMhp3BvHYxVBDDJo wSzQiQqRkfsGPMGMhFEjK8A32VHy2PfHC6F7xmWo/xgxX2aBpsuJ59KR0IQWug7GjwJj WoFqTAEdxs2HGBqck9+OF3X29ekep3a5+gVTzHZbFf1oLfZJIhOaQZ7fl1Hp+++TN0wJ Vve9/c/o419aoI41HzIDWdCI8XxUHadwakR847DcQ6CkHP+tPiR1EWJGNkw2bwTfhePF HaaA== X-Forwarded-Encrypted: i=1; AJvYcCXNabC9+QQKSYzQBnYmzyG181zKPBMVNmlx66uqUJBJiXhvzf9LlpRaD0lIl4Zobr5ksUR+aXc=@dpdk.org X-Gm-Message-State: AOJu0Yxuwg2MTYJBeqgL5vxI5q103pqahX2WXbKR5uCDtyyWladBWHuX EnpXB4j7YcPdwHSlosd+FPyWrfoAjlTvkjiFvDW1FcZ+wWBg7QypHcpKr459rcq8u2EMFFa8Rz9 DzTxu9n80YF4etC0Jv3Bv+fmt7M3f3fkfY3k4aCRAQw== X-Gm-Gg: ASbGncvMXgnwH/LkNmp2qo45NCO/12MILuqo2mU+N/5HUm0FX6+KcitOOU02hf0zSw5 ylN1p1fNsXISgkrIhJ+nEqFlwbjeJwly1ri+jPV3Dp0zdnkfuN8ENYg7g0aqDoCMnVWtwxojg8L ywmlLj6KrWuaqDDzu0JQaFuA+zrhduSByl6uQyIm0Wj0tPJsCEBTh0nQbKlydqYkN6nMDUidjMd DT2YNgfLwRsGju65dhlgoL1ykW5XbXHjM3A9ERaFw== X-Google-Smtp-Source: AGHT+IHpqxnzo3EHHixemO/eksvYm7Xb4nq41KHo9qsMoVzBKEv+gdoV7fygpuQDPCBaQfKBnuU2SQQHSLHVehLb7q4= X-Received: by 2002:a05:6214:dc6:b0:707:c5a:e577 with SMTP id 6a1803df08f44-7070c5aeddcmr436706d6.39.1753277197283; Wed, 23 Jul 2025 06:26:37 -0700 (PDT) MIME-Version: 1.0 References: <20250722115439.1353573-1-14pwcse1224@uetpeshawar.edu.pk> <20250723045022.1580829-1-14pwcse1224@uetpeshawar.edu.pk> In-Reply-To: From: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> Date: Wed, 23 Jul 2025 18:26:24 +0500 X-Gm-Features: Ac12FXyf4aX5VJJOtbypXdhrgDY2obtOhSXNrXU46I2qE9PuIkpIpdQdc8T6yw0 Message-ID: Subject: Re: [PATCH v2] lib/ethdev: fix segfault in secondary process by validating dev_private pointer To: Ivan Malov Cc: Stephen Hemminger , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , dev@dpdk.org, dpdk stable Content-Type: multipart/alternative; boundary="0000000000008989f8063a98a8d9" 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 --0000000000008989f8063a98a8d9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks, no. Can, I ? On Wed, Jul 23, 2025, 18:24 Ivan Malov wrote: > Hi Khadem, > > On Wed, 23 Jul 2025, Khadem Ullah wrote: > > > Please check v3 of this patch. > > Checked. In the meantime, you're not overlooking to mark previous version= s > [1] > with status 'SUPERSEDED' in DPDK Patchwork, are you? > > [1] > https://patches.dpdk.org/project/dpdk/patch/20250723045022.1580829-1-14pw= cse1224@uetpeshawar.edu.pk/ > > > > > On Wed, Jul 23, 2025 at 5:19=E2=80=AFPM Khadem Ullah < > 14pwcse1224@uetpeshawar.edu.pk> wrote: > > > > Secondary application not only breaking on device closing, > > it's also getting segfault when we do "show device info all" from > secondary > > after primary closes: > > testpmd> show device info all > > ********************* Infos for device 0000:03:00.0 *******************= ** > > Bus name: pci > > Bus information: vendor_id=3D15b3, device_id=3D101d > > Driver name: mlx5_pci > > Devargs: > > Connect to socket: 0 > > Segmentation fault (core dumped) > > This patch prevents these crashes and it seems that these fixes should > be in PMD along with the ethdev layer. Some more checks will be added in > the next version to prevent "show device i > > nfo all" crash. > > > > > > On Wed, Jul 23, 2025 at 9:50=E2=80=AFAM Khadem Ullah < > 14pwcse1224@uetpeshawar.edu.pk> wrote: > > In secondary processes, directly accessing > 'dev->data->dev_private' can > > cause a segmentation fault if the primary process has exited or i= f > the > > shared memory is no longer accessible. > > > > This patch adds a safety check using rte_mem_virt2phy(), with an > > unlikely() branch hint to minimize performance impact in the fast > path. > > This ensures 'dev_private' is still valid before accessing it. > > > > Fixes: bdad90d12ec8 ("ethdev: change device info get callback to > return int") > > Cc: stable@dpdk.org > > > > Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> > > --- > > lib/ethdev/rte_ethdev.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > > index dd7c00bc94..ef5dc55f2e 100644 > > --- a/lib/ethdev/rte_ethdev.c > > +++ b/lib/ethdev/rte_ethdev.c > > @@ -4079,6 +4079,13 @@ rte_eth_dev_info_get(uint16_t port_id, > struct rte_eth_dev_info *dev_info) > > > > if (dev->dev_ops->dev_infos_get =3D=3D NULL) > > return -ENOTSUP; > > + if (rte_eal_process_type() =3D=3D RTE_PROC_SECONDARY && > > + unlikely(rte_mem_virt2phy(dev->data->dev_private) > =3D=3D RTE_BAD_PHYS_ADDR)) { > > + RTE_ETHDEV_LOG_LINE(ERR, > > + "Secondary: dev_private not accessible > (primary exited?)"); > > + rte_errno =3D ENODEV; > > + return -rte_errno; > > + } > > diag =3D dev->dev_ops->dev_infos_get(dev, dev_info); > > if (diag !=3D 0) { > > /* Cleanup already filled in device information *= / > > -- > > 2.43.0 > > > > > > > > -- > > Engr. Khadem Ullah, > > Software Engineer, > > Dreambig Semiconductor Inc > > https://dreambigsemi.com/ > > > > > > > > -- > > Engr. Khadem Ullah, > > Software Engineer, > > Dreambig Semiconductor Inc > > https://dreambigsemi.com/ > > > > --0000000000008989f8063a98a8d9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks, no.=C2=A0
Can, I ?=C2=A0

On Wed, Jul 23, 2025, 18:24 Ivan Malov <ivan.malov@arknetworks.am> wrote:
Hi Khadem,

On Wed, 23 Jul 2025, Khadem Ullah wrote:

> Please check v3 of this patch.

Checked. In the meantime, you're not overlooking to mark previous versi= ons [1]
with status 'SUPERSEDED' in DPDK Patchwork, are you?

[1] https://patches.dpdk.org/project/dpdk/patch/20250723045022.1= 580829-1-14pwcse1224@uetpeshawar.edu.pk/

>
> On Wed, Jul 23, 2025 at 5:19=E2=80=AFPM Khadem Ullah <1= 4pwcse1224@uetpeshawar.edu.pk> wrote:
>
> Secondary application not only breaking on device closing,
> it's also getting segfault when we do "show device info all&q= uot; from secondary
> after primary closes:
> testpmd> show device info all
> ********************* Infos for device 0000:03:00.0 ******************= ***
> Bus name: pci
> Bus information: vendor_id=3D15b3, device_id=3D101d
> Driver name: mlx5_pci
> Devargs:
> Connect to socket: 0
> Segmentation fault (core dumped)
> This patch prevents these crashes and it seems that these fixes should= be in PMD along with the ethdev layer. Some more checks will be added in t= he next version to prevent "show device i
> nfo all" crash.
>
>
> On Wed, Jul 23, 2025 at 9:50=E2=80=AFAM Khadem Ullah <1= 4pwcse1224@uetpeshawar.edu.pk> wrote:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0In secondary processes, directly accessing &= #39;dev->data->dev_private' can
>=C2=A0 =C2=A0 =C2=A0 =C2=A0cause a segmentation fault if the primary pr= ocess has exited or if the
>=C2=A0 =C2=A0 =C2=A0 =C2=A0shared memory is no longer accessible.
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0This patch adds a safety check using rte_mem= _virt2phy(), with an
>=C2=A0 =C2=A0 =C2=A0 =C2=A0unlikely() branch hint to minimize performan= ce impact in the fast path.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0This ensures 'dev_private' is still = valid before accessing it.
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Fixes: bdad90d12ec8 ("ethdev: change de= vice info get callback to return int")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Cc: stable@dpdk.org
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Signed-off-by: Khadem Ullah <= 14pwcse1224@uetpeshawar.edu.pk>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0---
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0lib/ethdev/rte_ethdev.c | 7 +++++++ >=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A01 file changed, 7 insertions(+)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0diff --git a/lib/ethdev/rte_ethdev.c b/lib/e= thdev/rte_ethdev.c
>=C2=A0 =C2=A0 =C2=A0 =C2=A0index dd7c00bc94..ef5dc55f2e 100644
>=C2=A0 =C2=A0 =C2=A0 =C2=A0--- a/lib/ethdev/rte_ethdev.c
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+++ b/lib/ethdev/rte_ethdev.c
>=C2=A0 =C2=A0 =C2=A0 =C2=A0@@ -4079,6 +4079,13 @@ rte_eth_dev_info_get(= uint16_t port_id, struct rte_eth_dev_info *dev_info)
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (dev->dev_= ops->dev_infos_get =3D=3D NULL)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 return -ENOTSUP;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (rte_eal_proc= ess_type() =3D=3D RTE_PROC_SECONDARY &&
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0unlikely(rte_mem_virt2phy(dev->data->dev_private) =3D=3D= RTE_BAD_PHYS_ADDR)) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0RTE_ETHDEV_LOG_LINE(ERR,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Secondary: dev_private not a= ccessible (primary exited?)");
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rte_errno =3D ENODEV;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -rte_errno;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 diag =3D dev->= ;dev_ops->dev_infos_get(dev, dev_info);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (diag !=3D 0)= {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 /* Cleanup already filled in device information */
>=C2=A0 =C2=A0 =C2=A0 =C2=A0--
>=C2=A0 =C2=A0 =C2=A0 =C2=A02.43.0
>
>
>
> --
> Engr. Khadem Ullah,
> Software Engineer,
> Dreambig Semiconductor Inc
> https://dreambigsemi.com/
>
>
>
> --
> Engr. Khadem Ullah,
> Software Engineer,
> Dreambig Semiconductor Inc
> https://dreambigsemi.com/
>
>
--0000000000008989f8063a98a8d9--