[dpdk-dev] [PATCH] eal: Copy raw strings taken from command line

Thomas Monjalon thomas at monjalon.net
Mon Oct 9 23:27:11 CEST 2017


04/09/2017 12:12, Sergio Gonzalez Monroy:
> On 04/08/2017 19:53, Patrick MacArthur wrote:
> > Normally, command line argument strings are considered immutable, but
> > SPDK [1] and urdma [2] construct argv arrays to pass to rte_eal_init().
> > These strings are allocated using malloc() and freed after DPDK
> > initialization with free(). However, in the case of --file-prefix and
> > --huge-dir, DPDK takes the pointer to these strings in argv directly. If
> > a secondary process calls rte_eal_pci_probe() after rte_eal_init()
> > returns, as is done by SPDK, this causes a use-after-free error because
> > the strings have been freed by the calling code immediately after
> > rte_eal_init() returns.
[...]
> > Fix this by using strdup() to create separate memory buffers for these
> > strings. Note that this patch will cause valgrind to report memory
> > leaks of these buffers as there is nowhere to free them. Using static
> > buffers is an option but would make these strings have a fixed maximum
> > length whereas there is currently no limit defined by the API.
> >
> > [1] http://spdk.io
> > [2] https://github.com/zrlio/urdma
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable at dpdk.org
> >
> > Signed-off-by: Patrick MacArthur <patrick at patrickmacarthur.net>
> 
> Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy at intel.com>

Applied, thanks



More information about the dev mailing list