DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org, Sunyang Wu <sunyang.wu@jaguarmicro.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Olivier Matz <olivier.matz@6wind.com>
Subject: [PATCH] app/test-pmd: terminate process on second signal
Date: Mon, 27 Apr 2026 10:26:17 -0700	[thread overview]
Message-ID: <20260427172617.295684-1-stephen@networkplumber.org> (raw)
In-Reply-To: <20260427105741.14348-1-sunyang.wu@jaguarmicro.com>

The SIGINT/SIGTERM handler starts a graceful shutdown via
prompt_exit(), after which prompt() frees the cmdline object with
cmdline_stdin_exit(). A second signal delivered during or after
that free re-enters prompt_exit() and dereferences testpmd_cl,
producing a use-after-free.

Set SA_RESETHAND so the second signal terminates the process via
SIG_DFL instead of re-running the shutdown path. On Windows the
C runtime's signal() already resets the disposition after delivery,
so behavior is consistent without an #ifdef.

Fixes: f1d0993e034e ("app/testpmd: fix interactive mode on Windows")
Cc: stable@dpdk.org
Reported-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test-pmd/testpmd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e2569d9e30..d93c696057 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -4603,9 +4603,14 @@ main(int argc, char** argv)
 	signal(SIGINT, signal_handler);
 	signal(SIGTERM, signal_handler);
 #else
-	/* Want read() not to be restarted on signal */
+	/*
+	 * Do not restart read() on signal (no SA_RESTART), and reset
+	 * to SIG_DFL after first delivery so a second SIGINT/SIGTERM
+	 * terminates instead of re-entering the shutdown path.
+	 */
 	struct sigaction action = {
 		.sa_handler = signal_handler,
+		.sa_flags = SA_RESETHAND,
 	};
 
 	sigaction(SIGINT, &action, NULL);
-- 
2.53.0


  parent reply	other threads:[~2026-04-27 17:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 10:57 [PATCH v2] app/testpmd: avoid cmdline use-after-free on SIGINT Sunyang Wu
2026-04-27 11:13 ` [PATCH v3] " Sunyang Wu
2026-04-27 15:23   ` Stephen Hemminger
2026-04-27 17:26 ` Stephen Hemminger [this message]
2026-04-28  8:00   ` [PATCH] app/test-pmd: terminate process on second signal Bruce Richardson
2026-04-28 13:52   ` [PATCH v2] " Stephen Hemminger
2026-04-30 17:25     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260427172617.295684-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    --cc=sunyang.wu@jaguarmicro.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox