Re: [PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply

2021-04-04 Thread Ilya Maximets
CC: ovs-dev On 4/4/21 7:50 PM, Ilya Maximets wrote: > 'struct ovs_zone_limit' has more members than initialized in > ovs_ct_limit_get_default_limit(). The rest of the memory is a random > kernel stack content that ends up being sent to userspace. > > Fix that by using designa

[PATCH net] openvswitch: fix send of uninitialized stack memory in ct limit reply

2021-04-04 Thread Ilya Maximets
("openvswitch: Support conntrack zone limit") Signed-off-by: Ilya Maximets --- net/openvswitch/conntrack.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index c29b0ef1fc27..cadb6a29b285 100644

Re: [PATCH bpf v2] libbpf: fix passing uninitialized bytes to setsockopt

2019-10-13 Thread Ilya Maximets
On 13.10.2019 1:24, Alexei Starovoitov wrote: On Wed, Oct 09, 2019 at 06:49:29PM +0200, Ilya Maximets wrote: 'struct xdp_umem_reg' has 4 bytes of padding at the end that makes valgrind complain about passing uninitialized stack memory to the syscall: Syscall param socketcall.setsockopt

Re: [PATCH bpf] libbpf: fix passing uninitialized bytes to setsockopt

2019-10-13 Thread Ilya Maximets
On 13.10.2019 6:59, Alexei Starovoitov wrote: On Sat, Oct 12, 2019 at 9:52 PM Ilya Maximets wrote: 'struct xdp_umem_reg' has 4 bytes of padding at the end that makes valgrind complain about passing uninitialized stack memory to the syscall: Syscall param socketcall.setsockopt() points

[PATCH bpf v2] libbpf: fix passing uninitialized bytes to setsockopt

2019-10-09 Thread Ilya Maximets
flags to umem config") Signed-off-by: Ilya Maximets --- Version 2: * Struct initializer replaced with explicit memset(). [Andrii] tools/lib/bpf/xsk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c index a902838f9fcc..9d5348086203 100644 --- a/too

Re: [PATCH bpf] libbpf: fix passing uninitialized bytes to setsockopt

2019-10-09 Thread Ilya Maximets
On 09.10.2019 18:29, Andrii Nakryiko wrote: On Wed, Oct 9, 2019 at 8:43 AM Ilya Maximets wrote: 'struct xdp_umem_reg' has 4 bytes of padding at the end that makes valgrind complain about passing uninitialized stack memory to the syscall: Syscall param socketcall.setsockopt() points

[PATCH bpf] libbpf: fix passing uninitialized bytes to setsockopt

2019-10-09 Thread Ilya Maximets
: xsk_umem__create@@LIBBPF_0.0.4 (xsk.c:172) Uninitialised value was created by a stack allocation at 0x4BDDEBA: xsk_umem__create@@LIBBPF_0.0.4 (xsk.c:140) Padding bytes appeared after introducing of a new 'flags' field. Fixes: 10d30e301732 ("libbpf: add flags to umem config") Signed-of

Re: [PATCH net v3] ixgbe: fix double clean of tx descriptors with xdp

2019-08-27 Thread Ilya Maximets
On 26.08.2019 16:40, Maciej Fijalkowski wrote: > On Thu, 22 Aug 2019 20:12:37 +0300 > Ilya Maximets wrote: > >> Tx code doesn't clear the descriptors' status after cleaning. >> So, if the budget is larger than number of used elems in a ring, some >> descript

[PATCH net v3] ixgbe: fix double clean of tx descriptors with xdp

2019-08-22 Thread Ilya Maximets
F_XDP zero-copy Tx support") Signed-off-by: Ilya Maximets --- Version 3: * Reverted some refactoring made for v2. * Eliminated 'budget' for tx clean. * prefetch returned. Version 2: * 'ixgbe_clean_xdp_tx_irq()' refactored to look more like 'ixgbe_xsk_clean_tx_ring()'. drivers/ne

Re: [PATCH net v2] ixgbe: fix double clean of tx descriptors with xdp

2019-08-22 Thread Ilya Maximets
On 22.08.2019 19:38, Alexander Duyck wrote: > On Thu, Aug 22, 2019 at 5:30 AM Ilya Maximets wrote: >> >> Tx code doesn't clear the descriptors' status after cleaning. >> So, if the budget is larger than number of used elems in a ring, some >> descript

Re: [PATCH net] ixgbe: fix double clean of tx descriptors with xdp

2019-08-22 Thread Ilya Maximets
On 22.08.2019 19:07, William Tu wrote: > On Thu, Aug 22, 2019 at 1:17 AM Ilya Maximets wrote: >> >> On 22.08.2019 0:38, William Tu wrote: >>> On Wed, Aug 21, 2019 at 9:57 AM Alexander Duyck >>> wrote: >>>> >>>> On Wed, Aug 21, 2019 at 9:22

[PATCH net v2] ixgbe: fix double clean of tx descriptors with xdp

2019-08-22 Thread Ilya Maximets
to directly use 'next_to_clean' and 'next_to_use' indexes. Fixes: 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support") Signed-off-by: Ilya Maximets --- Version 2: * 'ixgbe_clean_xdp_tx_irq()' refactored to look more like 'ixgbe_xsk_clean_tx_ring()'. drivers/net/ethernet/intel/ixgbe/i

Re: [PATCH net] ixgbe: fix double clean of tx descriptors with xdp

2019-08-22 Thread Ilya Maximets
On 22.08.2019 0:38, William Tu wrote: > On Wed, Aug 21, 2019 at 9:57 AM Alexander Duyck > wrote: >> >> On Wed, Aug 21, 2019 at 9:22 AM Ilya Maximets wrote: >>> >>> On 21.08.2019 4:17, Alexander Duyck wrote: >>>> On Tue, Au

Re: [Intel-wired-lan] [PATCH net] ixgbe: fix double clean of tx descriptors with xdp

2019-08-22 Thread Ilya Maximets
On 22.08.2019 10:12, Björn Töpel wrote: > On Wed, 21 Aug 2019 at 18:57, Alexander Duyck > wrote: >> >> On Wed, Aug 21, 2019 at 9:22 AM Ilya Maximets wrote: >>> >>> On 21.08.2019 4:17, Alexander Duyck wrote: >>>> On Tue, Au

Re: [PATCH net] ixgbe: fix double clean of tx descriptors with xdp

2019-08-21 Thread Ilya Maximets
On 21.08.2019 4:17, Alexander Duyck wrote: > On Tue, Aug 20, 2019 at 8:58 AM Ilya Maximets wrote: >> >> On 20.08.2019 18:35, Alexander Duyck wrote: >>> On Tue, Aug 20, 2019 at 8:18 AM Ilya Maximets >>> wrote: >>>> >>>> Tx code do

Re: [PATCH net] ixgbe: fix double clean of tx descriptors with xdp

2019-08-20 Thread Ilya Maximets
On 20.08.2019 18:35, Alexander Duyck wrote: > On Tue, Aug 20, 2019 at 8:18 AM Ilya Maximets wrote: >> >> Tx code doesn't clear the descriptor status after cleaning. >> So, if the budget is larger than number of used elems in a ring, some >> descript

[PATCH net] ixgbe: fix double clean of tx descriptors with xdp

2019-08-20 Thread Ilya Maximets
the number of descriptors to clean by the number of used descriptors in the tx ring. Fixes: 8221c5eba8c1 ("ixgbe: add AF_XDP zero-copy Tx support") Signed-off-by: Ilya Maximets --- Not tested yet because of lack of available hardware. So, testing is very welcome. drivers/net/ethernet/i

[PATCH bpf] libbpf: fix using uninitialized ioctl results

2019-07-23 Thread Ilya Maximets
: add support for using AF_XDP sockets") Signed-off-by: Ilya Maximets --- tools/lib/bpf/xsk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c index 5007b5d4fd2c..c4f912dc30f9 100644 --- a/tools/lib/bpf/xsk.c +++ b/tools/lib

[PATCH bpf] xdp: fix potential deadlock on socket mutex

2019-07-08 Thread Ilya Maximets
rtnl_lock' could produce a deadlock here. Fix that by moving the 'rtnl_lock' before 'xs->lock' in the bind call chain (a). Reported-by: syzbot+bf64ec93de836d7f4...@syzkaller.appspotmail.com Fixes: 455302d1c9ae ("xdp: fix hang while unregistering device bound to xdp socket") Signed-off-by: Il

[PATCH bpf] xdp: fix possible cq entry leak

2019-07-04 Thread Ilya Maximets
' checking moved out from the loop since there is no point to check it there. Fixes: 35fcde7f8deb ("xsk: support for Tx") Signed-off-by: Ilya Maximets --- net/xdp/xsk.c | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index f5

[PATCH bpf v2] xdp: fix race on generic receive path

2019-07-03 Thread Ilya Maximets
of it is open with AF_XDP socket. Need to take a lock for each generic receive to avoid race. Fixes: c497176cb2e4 ("xsk: add Rx receive functions and poll support") Signed-off-by: Ilya Maximets --- Version 2: * spin_lock_irqsave --> spin_lock_bh. include/net/xdp_sock.h | 2 ++

Re: [PATCH bpf] xdp: fix race on generic receive path

2019-07-03 Thread Ilya Maximets
On 03.07.2019 3:40, Jakub Kicinski wrote: > On Tue, 2 Jul 2019 17:36:34 +0300, Ilya Maximets wrote: >> Unlike driver mode, generic xdp receive could be triggered >> by different threads on different CPU cores at the same time >> leading to the fill and rx queue

Re: [PATCH bpf] xdp: fix race on generic receive path

2019-07-02 Thread Ilya Maximets
On 02.07.2019 18:01, Magnus Karlsson wrote: > On Tue, Jul 2, 2019 at 4:36 PM Ilya Maximets wrote: >> >> Unlike driver mode, generic xdp receive could be triggered >> by different threads on different CPU cores at the same time >> leading to the fill and rx

[PATCH bpf] xdp: fix race on generic receive path

2019-07-02 Thread Ilya Maximets
of it is open with AF_XDP socket. Need to take a lock for each generic receive to avoid race. Fixes: c497176cb2e4 ("xsk: add Rx receive functions and poll support") Signed-off-by: Ilya Maximets --- include/net/xdp_sock.h | 2 ++ net/xdp/xsk.c | 32 +++

[PATCH bpf v6 2/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-28 Thread Ilya Maximets
event notification handler to properly clean up all the resources and unref device. This should also allow socket killing via ss(8) utility. Fixes: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Ilya Maximets Acked-by: Jonathan Lemon --- include/net/xdp_sock.h | 5 +++ ne

[PATCH bpf v6 0/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-28 Thread Ilya Maximets
: * Declaration lines ordered from longest to shortest. * Checking of event type moved to the top to avoid unnecessary locking. Version 2: * Completely re-implemented using netdev event handler. Ilya Maximets (2): xdp: hold device for umem regardless of zero-copy mode xdp: fix

[PATCH bpf v6 1/2] xdp: hold device for umem regardless of zero-copy mode

2019-06-28 Thread Ilya Maximets
Device pointer stored in umem regardless of zero-copy mode, so we heed to hold the device in all cases. Fixes: c9b47cc1fabc ("xsk: fix bug when trying to use both copy and zero-copy on one queue id") Signed-off-by: Ilya Maximets Acked-by: Jonathan Lemon --- net/xdp/xdp_u

Re: [PATCH bpf v5 2/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-28 Thread Ilya Maximets
On 28.06.2019 1:04, Jonathan Lemon wrote: > On 27 Jun 2019, at 3:15, Ilya Maximets wrote: > >> Device that bound to XDP socket will not have zero refcount until the >> userspace application will not close it. This leads to hang inside >> 'netdev_wait_allrefs()' if device

[PATCH bpf v5 1/2] xdp: hold device for umem regardless of zero-copy mode

2019-06-27 Thread Ilya Maximets
Device pointer stored in umem regardless of zero-copy mode, so we heed to hold the device in all cases. Fixes: c9b47cc1fabc ("xsk: fix bug when trying to use both copy and zero-copy on one queue id") Signed-off-by: Ilya Maximets --- net/xdp/xdp_umem.c | 11 ++- 1 file

[PATCH bpf v5 0/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-27 Thread Ilya Maximets
to shortest. * Checking of event type moved to the top to avoid unnecessary locking. Version 2: * Completely re-implemented using netdev event handler. Ilya Maximets (2): xdp: hold device for umem regardless of zero-copy mode xdp: fix hang while unregistering device bound to xdp

[PATCH bpf v5 2/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-27 Thread Ilya Maximets
event notification handler to properly clean up all the resources and unref device. This should also allow socket killing via ss(8) utility. Fixes: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Ilya Maximets --- include/net/xdp_sock.h | 5 +++ net/xdp/xdp_umem.c | 1

Re: [PATCH bpf v4 2/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-27 Thread Ilya Maximets
On 26.06.2019 21:34, Jakub Kicinski wrote: > On Wed, 26 Jun 2019 21:15:15 +0300, Ilya Maximets wrote: >> diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c >> index 267b82a4cbcf..56729e74cbea 100644 >> --- a/net/xdp/xdp_umem.c >> +++ b/net/xdp/xdp_umem.c &

[PATCH bpf v4 2/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-26 Thread Ilya Maximets
event notification handler to properly clean up all the resources and unref device. This should also allow socket killing via ss(8) utility. Fixes: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Ilya Maximets --- include/net/xdp_sock.h | 5 +++ net/xdp/xdp_umem.c | 16 +

[PATCH bpf v4 0/2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-26 Thread Ilya Maximets
to avoid unnecessary locking. Version 2: * Completely re-implemented using netdev event handler. Ilya Maximets (2): xdp: hold device for umem regardless of zero-copy mode xdp: fix hang while unregistering device bound to xdp socket include/net/xdp_sock.h | 5 +++ net/xdp/xdp_umem.c

[PATCH bpf v4 1/2] xdp: hold device for umem regardless of zero-copy mode

2019-06-26 Thread Ilya Maximets
Device pointer stored in umem regardless of zero-copy mode, so we heed to hold the device in all cases. Fixes: c9b47cc1fabc ("xsk: fix bug when trying to use both copy and zero-copy on one queue id") Signed-off-by: Ilya Maximets --- net/xdp/xdp_umem.c | 11 ++- 1 file

Re: [PATCH bpf v3] xdp: fix hang while unregistering device bound to xdp socket

2019-06-11 Thread Ilya Maximets
On 11.06.2019 15:13, Björn Töpel wrote: > On Tue, 11 Jun 2019 at 10:42, Ilya Maximets wrote: >> >> On 11.06.2019 11:09, Björn Töpel wrote: >>> On Mon, 10 Jun 2019 at 22:49, Jonathan Lemon >>> wrote: >>>> >>>> On 10 Jun 2019, at 9:15,

Re: [PATCH bpf v3] xdp: fix hang while unregistering device bound to xdp socket

2019-06-11 Thread Ilya Maximets
On 11.06.2019 11:09, Björn Töpel wrote: > On Mon, 10 Jun 2019 at 22:49, Jonathan Lemon wrote: >> >> On 10 Jun 2019, at 9:15, Ilya Maximets wrote: >> >>> Device that bound to XDP socket will not have zero refcount until the >>> userspace application will

Re: [PATCH bpf v2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-10 Thread Ilya Maximets
On 10.06.2019 11:05, Ilya Maximets wrote: > On 08.06.2019 2:31, Jakub Kicinski wrote: >> On Fri, 7 Jun 2019 20:31:43 +0300, Ilya Maximets wrote: >>> +static int xsk_notifier(struct notifier_block *this, >>> + unsigned long msg, void *ptr) >

[PATCH bpf v3] xdp: fix hang while unregistering device bound to xdp socket

2019-06-10 Thread Ilya Maximets
event notification handler to properly clean up all the resources and unref device. This should also allow socket killing via ss(8) utility. Fixes: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Ilya Maximets --- Version 3: * Declaration lines ordered from lon

Re: [PATCH bpf v2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-10 Thread Ilya Maximets
On 08.06.2019 2:31, Jakub Kicinski wrote: > On Fri, 7 Jun 2019 20:31:43 +0300, Ilya Maximets wrote: >> +static int xsk_notifier(struct notifier_block *this, >> +unsigned long msg, void *ptr) >> +{ >> +struct sock *sk; >

[PATCH bpf v2] xdp: fix hang while unregistering device bound to xdp socket

2019-06-07 Thread Ilya Maximets
event notification handler to properly clean up all the resources and unref device. This should also allow socket killing via ss(8) utility. Fixes: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Ilya Maximets --- net/xdp/xsk.c | 62 +++

[PATCH bpf] xdp: check device pointer before clearing

2019-06-07 Thread Ilya Maximets
We should not call 'ndo_bpf()' or 'dev_put()' with NULL argument. Fixes: c9b47cc1fabc ("xsk: fix bug when trying to use both copy and zero-copy on one queue id") Signed-off-by: Ilya Maximets --- I'm not sure if this fixes any real NULL pointer dereference, but code is not consist

Re: [PATCH] net: Fix hang while unregistering device bound to xdp socket

2019-06-07 Thread Ilya Maximets
On 06.06.2019 21:03, Jonathan Lemon wrote: > On 6 Jun 2019, at 5:40, Ilya Maximets wrote: > >> Device that bound to XDP socket will not have zero refcount until the >> userspace application will not close it. This leads to hang inside >> 'netdev_wait_allrefs()' if device

[PATCH] net: Fix hang while unregistering device bound to xdp socket

2019-06-06 Thread Ilya Maximets
device and failing RTM_DELLINK with EBUSY if device is still in use by any XDP socket. With this change: # ip link del p1 RTNETLINK answers: Device or resource busy Fixes: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Ilya Maximets --- Another option could be to f