Message ID | 20191009141758.12687-1-i.maximets@ovn.org |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev] netdev-afxdp: Fix umem creation failure due to uninitialized config. | expand |
On Wed, Oct 09, 2019 at 04:17:58PM +0200, Ilya Maximets wrote: > Later version of 'struct xsk_umem_config' contains additional field > 'flags'. OVS doesn't use that field passing uninitialized stack > memory to the 'xsk_umem__create()' call that could fail with > 'Invalid argument' if 'flags' are non-zero or, even worse, create > umem with unexpected properties. > > We need to clear the whole structure explicitly to avoid this kind > of issues. > > Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.") > Signed-off-by: Ilya Maximets <i.maximets@ovn.org> > --- Thanks for the patch. I applied to master. --William
On 10.10.2019 20:21, William Tu wrote: > On Wed, Oct 09, 2019 at 04:17:58PM +0200, Ilya Maximets wrote: >> Later version of 'struct xsk_umem_config' contains additional field >> 'flags'. OVS doesn't use that field passing uninitialized stack >> memory to the 'xsk_umem__create()' call that could fail with >> 'Invalid argument' if 'flags' are non-zero or, even worse, create >> umem with unexpected properties. >> >> We need to clear the whole structure explicitly to avoid this kind >> of issues. >> >> Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.") >> Signed-off-by: Ilya Maximets <i.maximets@ovn.org> >> --- > > Thanks for the patch. > I applied to master. Thanks, William. As this is a bug fix it needs to be backported to 2.12. Best regards, Ilya Maximets.
On Fri, Oct 11, 2019 at 01:16:55PM +0200, Ilya Maximets wrote: > On 10.10.2019 20:21, William Tu wrote: > >On Wed, Oct 09, 2019 at 04:17:58PM +0200, Ilya Maximets wrote: > >>Later version of 'struct xsk_umem_config' contains additional field > >>'flags'. OVS doesn't use that field passing uninitialized stack > >>memory to the 'xsk_umem__create()' call that could fail with > >>'Invalid argument' if 'flags' are non-zero or, even worse, create > >>umem with unexpected properties. > >> > >>We need to clear the whole structure explicitly to avoid this kind > >>of issues. > >> > >>Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.") > >>Signed-off-by: Ilya Maximets <i.maximets@ovn.org> > >>--- > > > >Thanks for the patch. > >I applied to master. > > Thanks, William. > As this is a bug fix it needs to be backported to 2.12. > > Best regards, Ilya Maximets. Done, Thanks William
diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c index 6e0180327..4619245a8 100644 --- a/lib/netdev-afxdp.c +++ b/lib/netdev-afxdp.c @@ -168,6 +168,7 @@ xsk_configure_umem(void *buffer, uint64_t size, int xdpmode) umem = xzalloc(sizeof *umem); + memset(&uconfig, 0, sizeof uconfig); uconfig.fill_size = PROD_NUM_DESCS; uconfig.comp_size = CONS_NUM_DESCS; uconfig.frame_size = FRAME_SIZE;
Later version of 'struct xsk_umem_config' contains additional field 'flags'. OVS doesn't use that field passing uninitialized stack memory to the 'xsk_umem__create()' call that could fail with 'Invalid argument' if 'flags' are non-zero or, even worse, create umem with unexpected properties. We need to clear the whole structure explicitly to avoid this kind of issues. Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.") Signed-off-by: Ilya Maximets <i.maximets@ovn.org> --- lib/netdev-afxdp.c | 1 + 1 file changed, 1 insertion(+)