[dpdk-dev] [PATCH] vhost: fix external mbuf creation

Maxime Coquelin maxime.coquelin at redhat.com
Fri Oct 9 09:24:07 CEST 2020



On 10/7/20 2:53 PM, Olivier Matz wrote:
> In virtio_dev_extbuf_alloc(), the shinfo structure used to store
> the reference counter and the free callback of the external buffer
> is by default stored inside the mbuf data.
> 
> This is wrong because the mbuf (and its data) can be freed before
> the external buffer, for instance in the following situation:
> 
>   pkt2 = rte_pktmbuf_alloc(mp);
>   rte_pktmbuf_attach(pkt2, pkt);
>   rte_pktmbuf_free(pkt);
> 
> After this, pkt is freed, but it still contains shinfo, which is
> referenced by pkt2.
> 
> Fix this by always storing the shinfo beside the external buffer.
> 
> Fixes: c3ff0ac70acb ("vhost: improve performance by supporting large buffer")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
> ---
> 
> Hi,
> 
> I found this issue by code review while discussing about this
> patchset [1]. I did not tested the patch, but as I'm only removing
> one path among the two, I don't expect that it breaks anything.
> 
> [1] http://inbox.dpdk.org/dev/20200730120900.108232-1-yang_y_yi@163.com/
> 
> Regards,
> Olivier
> 
>  lib/librte_vhost/virtio_net.c | 30 ++++++++----------------------
>  1 file changed, 8 insertions(+), 22 deletions(-)

Applied to dpdk-next-virtio/main.

Thanks,
Maxime



More information about the dev mailing list