[PATCH] net/af_packet: fix crash in secondary process
Thomas Monjalon
thomas at monjalon.net
Fri Sep 12 11:32:02 CEST 2025
12/09/2025 10:47, Kerem Aksu:
> dumpcap crashes when trying to capture from af_packet devices. This is
> caused by allocating interface name with
> strdup (i.e. malloc). Interface name is not accessible from secondary
> process and causes segmentation fault. Use rte_malloc instead of
> strdup to fix the issue.
I agree with the analysis, thank you.
[...]
> - (*internals)->if_name = strdup(pair->value);
> + (*internals)->if_name = rte_zmalloc_socket(name, ifnamelen + 1,
> + 0, numa_node);
Probably no need to go on the next line, you are allowed to go to 100 characters per line.
If a second line is needed, only 2 tabs are required.
Why zmalloc? Probably no need to zero it.
> if ((*internals)->if_name == NULL)
> goto free_internals;
> + memcpy((*internals)->if_name, pair->value, ifnamelen);
> + (*internals)->if_name[ifnamelen] = '\0';
We can use a string-specialized function, like strlcpy.
More information about the dev
mailing list