Skip to content

Give EAL a scratch copy of the pointer array to avoid double free - #1098

Open
Frodocz wants to merge 1 commit into
F-Stack:devfrom
Frodocz:hotfix/fix-dpdk-argv-double-free
Open

Frodocz wants to merge 1 commit into
F-Stack:devfrom
Frodocz:hotfix/fix-dpdk-argv-double-free

Conversation

@Frodocz

@Frodocz Frodocz commented Oct 26, 2026

Copy link
Copy Markdown

Detailed descriptions will be shown in #1089.

ff_init() passes the global dpdk_argv[] straight to rte_eal_init(). DPDK's argument parser overwrites one slot with the program name at the end of parsing (lib/eal/linux/eal.c, eal_parse_args()):

if (optind >= 0)
    argv[optind-1] = prgname;

All F-Stack EAL arguments are options, so optind == argc and dpdk_argv[argc-1] now points to the same string as dpdk_argv[0]. With the default config, gdb after rte_eal_init() shows:

dpdk_argc = 4
dpdk_argv[0] = 0x555557737650 "f-stack"
dpdk_argv[1] = 0x5555577450d0 "-c1"
dpdk_argv[2] = 0x555557742780 "-n4"
dpdk_argv[3] = 0x555557737650 "f-stack"     <- was "--proc-type=auto"

ff_unload_config() (new in 2.0) frees every dpdk_argv[i], so "f-stack" is freed twice. The original dpdk_argv[argc-1] string leaks, which is the 17-byte dpdk_args_setup leak reported in #1089 on master. Any config hits this, because -c/-n are always generated.

The fix gives EAL a scratch copy of the pointer array, so dpdk_argv[] keeps the pointers ff_unload_config() owns. With the patch, the same repro under ASan runs to the end of ff_run() with no double free, and the dpdk_args_setup leak is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant