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 1B662462BB; Tue, 25 Feb 2025 21:42:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC5D6402DA; Tue, 25 Feb 2025 21:42:32 +0100 (CET) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mails.dpdk.org (Postfix) with ESMTP id 01B7D402D7 for ; Tue, 25 Feb 2025 21:42:31 +0100 (CET) Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2fcb6c42c47so9450041a91.1 for ; Tue, 25 Feb 2025 12:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1740516151; x=1741120951; 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=1keVYdTwMzjyuqetjBJAgYXNzUgy9wBOSM00bn8rR7I=; b=XGBCbXNC+Xy8p+N2KeQz/JtxOIX0npYAPuNTG+HfUJdYfJhVhX8TrF2E6ZeENJKDPq heZcdQxDFC8m0e1/MPYheFmUWnx7ybK/ihFBQ01GL/B7pWyPlIw/Pl2cDaf8ETZR7Rm+ JNeZWpwTEcet7C8mQNvTy9NnCv/5GIQxq+MqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740516151; x=1741120951; 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=1keVYdTwMzjyuqetjBJAgYXNzUgy9wBOSM00bn8rR7I=; b=dRNasVf6/rrBlqN8BehX4t5mAehGgfdaN/Dmgdyp2/tdK12T5A50ljPKFAN+Y3WshL 2ILcb7/CYOJN/K4D3bPq70FLdWeQyPi4gKKLCFHk0v3rA2NZmgyT3gghi00LPBZfHfgO D+cCAR00mvzfh6Qowf3N03+qAzdS34eNd5IEgB93NUtUaBpL6F/MQDZS3KDRzqgWd3Fx nxtvKsXAImeA3/g4QBLLCtf0xopl7esGoQSwoXO4YRyaHWKE4PRi3+in4T4vPpRsSaQT KisSk74ZgvR8z7zafdBq7pEwOszlgBKAPa8OW2PpmJIL9c4sj5F7fuNtoZIg9BK+1Lwm +LJw== X-Gm-Message-State: AOJu0YxUMJXUsxSuwbSCq2GlcofyS7DGUyVkPwb9i9lskC9U7DN21W0/ CLbBN1ElyJ8XRm7HZJWM5Ar/8LzhUJtn9P93LY9ByIdeUEdkwYoCz7KCvMZwuHTELDpUwUwSoS4 gIovfSOiedxlCZTl2K0FdBzDI/8fuw1dIxrZL7w== X-Gm-Gg: ASbGncsX7+j3tFlDlzLfdH5oo+qlEXWgw1pQ3cDSVmiNhaUeS9BpazBTd9EvXSI1WFj kPH+PVx+tUZ+FQmSCgKGitpFwqpKJpigC4YMy8uUWD0mwHenZeTI0FrlleCrd1ERdQz7BxWvz/1 6Wxwnwjq2NKGot3bBLzCtzF6oSTuj8t8IdR4stWEa8 X-Google-Smtp-Source: AGHT+IEiEeJUJzaOUOOoJrTgTJReD5jwh2vJzs3ZtrKqFBIqOyocRS9iwEb9lcRTv3q2d4YSr5Y2ezD814QtTQEqAUw= X-Received: by 2002:a17:90b:2dc6:b0:2fa:1e3e:9be5 with SMTP id 98e67ed59e1d1-2fe68a2df32mr8840016a91.0.1740516149548; Tue, 25 Feb 2025 12:42:29 -0800 (PST) MIME-Version: 1.0 References: <20250216160833.3216001-1-ariel.otilibili@6wind.com> <20250223214123.447579-1-ariel.otilibili@6wind.com> <20250223214123.447579-2-ariel.otilibili@6wind.com> In-Reply-To: <20250223214123.447579-2-ariel.otilibili@6wind.com> From: Patrick Robb Date: Tue, 25 Feb 2025 15:39:03 -0500 X-Gm-Features: AWEUYZkkYC02ZV33iIWvYL34SaPAU71M_rCaTZ--iuT6SywrtQY6wYW7TmZVH9I Message-ID: Subject: Re: [PATCH v2 1/1] pcapng: warn if NULL is passed to rte_pcapng_close To: Ariel Otilibili Cc: dev@dpdk.org Content-Type: multipart/alternative; boundary="000000000000d1f616062efd7edd" 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 --000000000000d1f616062efd7edd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Recheck-request: iol-marvell-Functional Putting in a recheck as I believe the fail CI reported is false. On Sun, Feb 23, 2025 at 4:41=E2=80=AFPM Ariel Otilibili wrote: > rte_pcapng_close() might dereference a null pointer; as example, > PVS-Studio gives its usage in test_pcapng.c: indeed, that call to > rte_pcapng_close() might receive a null pointer. > > In that case, rte_errno is set to EINVAL. The API is updated accordingly. > > Link: https://pvs-studio.com/en/docs/warnings/v522/ > Link: > https://github.com/DPDK/dpdk/blob/e5176f23ae8b31437c3e5eb875c81f95bf3a994= 2/app/test/test_pcapng.c#L438 > Fixes: 8d23ce8f5ee9 ("pcapng: add new library for writing pcapng files") > Signed-off-by: Ariel Otilibili > --- > .mailmap | 2 +- > lib/pcapng/rte_pcapng.c | 3 +++ > lib/pcapng/rte_pcapng.h | 2 ++ > 3 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/.mailmap b/.mailmap > index a03d3cfb591b..ea68d6180ccc 100644 > --- a/.mailmap > +++ b/.mailmap > @@ -135,7 +135,7 @@ Anupam Kapoor > Apeksha Gupta > Archana Muniganti < > muniganti.archana@caviumnetworks.com> > Archit Pandey > -Ariel Otilibili > +Ariel Otilibili > Arkadiusz Kubalewski > Arkadiusz Kusztal > Arnaud Fiorini > diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c > index 16485b27cb46..d2cbcea42885 100644 > --- a/lib/pcapng/rte_pcapng.c > +++ b/lib/pcapng/rte_pcapng.c > @@ -716,6 +716,9 @@ rte_pcapng_fdopen(int fd, > void > rte_pcapng_close(rte_pcapng_t *self) > { > + if (!self) > + rte_errno =3D EINVAL; > + > close(self->outfd); > free(self); > } > diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h > index 48f2b5756430..f7b976987320 100644 > --- a/lib/pcapng/rte_pcapng.h > +++ b/lib/pcapng/rte_pcapng.h > @@ -60,6 +60,8 @@ rte_pcapng_fdopen(int fd, > * > * @param self > * handle to library > + > + * If self is NULL, rte_errno is set to EINVAL. > */ > void > rte_pcapng_close(rte_pcapng_t *self); > -- > 2.30.2 > > --000000000000d1f616062efd7edd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Recheck-request: iol-marvell-Functional

Putting in a recheck as I believe the fail CI reported is false.

On Sun, Feb 23, 2025 at 4:41=E2=80=AFPM Ariel Otilibili &= lt;ariel.otilibili@6wind.com> wrote:
rt= e_pcapng_close() might dereference a null pointer; as example,
PVS-Studio gives its usage in test_pcapng.c: indeed, that call to
rte_pcapng_close() might receive a null pointer.

In that case, rte_errno is set to EINVAL. The API is updated accordingly.
Link:
https://pvs-studio.com/en/docs/warnings/v522/=
Link: https://github.com/DPDK/dpdk/blob/e5176f23ae8b31437c3e5eb875c81f95b= f3a9942/app/test/test_pcapng.c#L438
Fixes: 8d23ce8f5ee9 ("pcapng: add new library for writing pcapng files= ")
Signed-off-by: Ariel Otilibili <ariel.otilibili@6wind.com>
---
=C2=A0.mailmap=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | 2 += -
=C2=A0lib/pcapng/rte_pcapng.c | 3 +++
=C2=A0lib/pcapng/rte_pcapng.h | 2 ++
=C2=A03 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/.mailmap b/.mailmap
index a03d3cfb591b..ea68d6180ccc 100644
--- a/.mailmap
+++ b/.mailmap
@@ -135,7 +135,7 @@ Anupam Kapoor <anupam.kapoor@gmail.com>
=C2=A0Apeksha Gupta <apeksha.gupta@nxp.com>
=C2=A0Archana Muniganti <marchana@marvell.com> <muniganti.archana@caviumnetwork= s.com>
=C2=A0Archit Pandey <architpandeynitk@gmail.com>
-Ariel Otilibili <otilibil@eurecom.fr> <ariel.otilibili@6wind.com>
+Ariel Otilibili <ariel.otilibili@6wind.com> <otilibil@eurecom.fr>
=C2=A0Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
=C2=A0Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
=C2=A0Arnaud Fiorini <arnaud.fiorini@polymtl.ca>
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 16485b27cb46..d2cbcea42885 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -716,6 +716,9 @@ rte_pcapng_fdopen(int fd,
=C2=A0void
=C2=A0rte_pcapng_close(rte_pcapng_t *self)
=C2=A0{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!self)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rte_errno =3D EINVA= L;
+
=C2=A0 =C2=A0 =C2=A0 =C2=A0 close(self->outfd);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 free(self);
=C2=A0}
diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h
index 48f2b5756430..f7b976987320 100644
--- a/lib/pcapng/rte_pcapng.h
+++ b/lib/pcapng/rte_pcapng.h
@@ -60,6 +60,8 @@ rte_pcapng_fdopen(int fd,
=C2=A0 *
=C2=A0 * @param self
=C2=A0 *=C2=A0 handle to library
+
+ * If self is NULL, rte_errno is set to EINVAL.
=C2=A0 */
=C2=A0void
=C2=A0rte_pcapng_close(rte_pcapng_t *self);
--
2.30.2

--000000000000d1f616062efd7edd--