[PATCH v3] app/testpmd: avoid cmdline use-after-free on SIGINT
Stephen Hemminger
stephen at networkplumber.org
Mon Apr 27 17:23:50 CEST 2026
On Mon, 27 Apr 2026 19:13:47 +0800
Sunyang Wu <sunyang.wu at jaguarmicro.com> wrote:
> When testpmd runs in interactive mode, SIGINT is handled by setting
> the quit flag and calling prompt_exit() so the cmdline input path can
> be interrupted.
>
> However, prompt() frees the cmdline object with cmdline_stdin_exit()
> after cmdline_interact() returns, while the global testpmd_cl pointer
> may still be observed by a later signal during shutdown. If SIGINT
> arrives after the cmdline object is freed, prompt_exit() may call
> cmdline_quit() on stale state and trigger a use-after-free.
>
> Keep the existing prompt_exit() behavior so interactive input can
> still be cancelled, but move the cmdline object lifetime under a
> local pointer and use atomic load/store for testpmd_cl so the signal
> path cannot observe freed state.
>
> This preserves the interactive-mode fix introduced for Windows while
> avoiding a shutdown-time use-after-free.
>
> Fixes: f1d0993e034e ("app/testpmd: fix interactive mode on Windows")
> Cc: stable at dpdk.org
>
> Signed-off-by: Sunyang Wu <sunyang.wu at jaguarmicro.com>
> ---
You don't need stdatomic here, it is over kill.
The signal and command line will run on thread.
It would be better to disarm the signal and make it a one shot
situation.
More information about the stable
mailing list