[PATCH v2] can: mcba_usb: Fix memory leak when cancelling urb

2021-01-11 Thread Bui Quang Minh
In mcba_usb_read_bulk_callback(), when we don't resubmit or fails to resubmit the urb, we need to deallocate the transfer buffer that is allocated in mcba_usb_start(). Reported-by: syzbot+57281c762a3922e14...@syzkaller.appspotmail.com Signed-off-by: Bui Quang Minh --- v1: add memory lea

Re: [PATCH v2] can: mcba_usb: Fix memory leak when cancelling urb

2021-01-11 Thread Bui Quang Minh
On Mon, Jan 11, 2021 at 01:00:31PM +0100, Oliver Neukum wrote: > Am Montag, den 11.01.2021, 10:49 + schrieb Bui Quang Minh: > > In mcba_usb_read_bulk_callback(), when we don't resubmit or fails to > > resubmit the urb, we need to deallocate the transfer buffer that

[PATCH v3] can: mcba_usb: Fix memory leak when cancelling urb

2021-01-11 Thread Bui Quang Minh
urbs and free them later. Reported-by: syzbot+57281c762a3922e14...@syzkaller.appspotmail.com Signed-off-by: Bui Quang Minh --- v1: add memory leak fix when not resubmitting urb v2: add memory leak fix when failing to resubmit urb v3: remove usb_free_coherent() calls in interrupt context driver

Re: memory leak in mcba_usb_probe

2021-01-10 Thread Bui Quang Minh
#syz test: https://github.com/minhbq-99/linux.git 080e743dff190ee8ebec63a13ac33fe8b7e4fc9e

[PATCH] can: mcba_usb: Fix memory leak when cancelling urb

2021-01-10 Thread Bui Quang Minh
In mcba_usb_read_bulk_callback(), when we don't resubmit the urb, we need to deallocate the transfer buffer that is allocated in mcba_usb_start(). Reported-by: syzbot+57281c762a3922e14...@syzkaller.appspotmail.com Signed-off-by: Bui Quang Minh --- drivers/net/can/usb/mcba_usb.c | 2 ++ 1

[PATCH] userfaultfd: Write protect when virtual memory range has no page table entry

2021-03-19 Thread Bui Quang Minh
entry in missing page table entry page fault path. Signed-off-by: Bui Quang Minh --- mm/huge_memory.c | 12 mm/memory.c | 10 ++ 2 files changed, 22 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index ae907a9c2050..9bb16a55a48c 100644 --- a/mm/huge_me

Re: [PATCH] userfaultfd: Write protect when virtual memory range has no page table entry

2021-03-22 Thread Bui Quang Minh
On Mon, Mar 22, 2021 at 03:00:37PM +0200, Mike Rapoport wrote: > On Mon, Mar 22, 2021 at 11:14:37AM +0100, Michal Hocko wrote: > > Le'ts Andrea and Mike > > > > On Fri 19-03-21 22:24:28, Bui Quang Minh wrote: > > > userfaultfd_writeprotect() use change

[PATCH] USB: dummy-hcd: Fix uninitialized array use in init()

2020-12-03 Thread Bui Quang Minh
This error path err_add_pdata: for (i = 0; i < mod_data.num; i++) kfree(dum[i]); can be triggered when not all dum's elements are initialized. Fix this by initializing all dum's elements to NULL. Signed-off-by: Bui Quang Minh ---

Re: [PATCH] USB: dummy-hcd: Fix uninitialized array use in init()

2020-12-06 Thread Bui Quang Minh
On Sat, Dec 05, 2020 at 10:15:11AM -0500, Alan Stern wrote: > On Sat, Dec 05, 2020 at 07:47:01PM +0700, Minh Bùi Quang wrote: > > Vào Th 6, 4 thg 12, 2020 vào lúc 23:12 Alan Stern > > đã viết: > > > Does this initialization end up using less memory than an explicit > > > memset() call? > > > >

[no subject]

2021-01-21 Thread Bui Quang Minh
Bcc: Subject: Re: [PATCH v2] can: mcba_usb: Fix memory leak when cancelling urb Reply-To: In-Reply-To: On Tue, Jan 12, 2021 at 01:42:33PM +0700, Minh Bùi Quang wrote: > On Mon, Jan 11, 2021 at 9:31 PM Bui Quang Minh > wrote: > > > > On Mon, Jan 11, 2021 at 01:00:31PM +0

Re: [PATCH v2] can: mcba_usb: Fix memory leak when cancelling urb

2021-01-21 Thread Bui Quang Minh
On Tue, Jan 12, 2021 at 01:42:33PM +0700, Minh Bùi Quang wrote: > On Mon, Jan 11, 2021 at 9:31 PM Bui Quang Minh > wrote: > > > > On Mon, Jan 11, 2021 at 01:00:31PM +0100, Oliver Neukum wrote: > > > Am Montag, den 11.01.2021, 10:49 + schrieb

[PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Bui Quang Minh
. Signed-off-by: Bui Quang Minh --- kernel/bpf/devmap.c | 4 ++-- net/core/sock_map.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c index f6e9c68afdd4..e849c3e8a49f 100644 --- a/kernel/bpf/devmap.c +++ b/kernel/bpf/devmap.c @@ -92,7

Re: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Bui Quang Minh
On Tue, Jan 26, 2021 at 09:36:57AM +, Lorenz Bauer wrote: > On Tue, 26 Jan 2021 at 08:26, Bui Quang Minh wrote: > > > > In 32-bit architecture, the result of sizeof() is a 32-bit integer so > > the expression becomes the multiplication between 2 32-bit integer which >

Re: [PATCH] bpf: Fix integer overflow in argument calculation for bpf_map_area_alloc

2021-01-26 Thread Bui Quang Minh
On Wed, Jan 27, 2021 at 11:23:41AM +0700, Bui Quang Minh wrote: > > * Seems like there are quite a few similar calls scattered around > > (cpumap, etc.). Did you audit these as well? > > I spotted another bug after re-auditting. In hashtab, there ares 2 places > u

[PATCH] bpf: Check for integer overflow when using roundup_pow_of_two()

2021-01-26 Thread Bui Quang Minh
On 32-bit architecture, roundup_pow_of_two() can return 0 when the argument has upper most bit set due to resulting 1UL << 32. Add a check for this case. Fixes: d5a3b1f ("bpf: introduce BPF_MAP_TYPE_STACK_TRACE") Signed-off-by: Bui Quang Minh --- kernel/bpf/stackmap.c | 2 ++ 1

Re: [PATCH] virtio-net: disable delayed refill when setting up xdp

2025-04-05 Thread Bui Quang Minh
On 4/2/25 12:42, Bui Quang Minh wrote: When setting up XDP for a running interface, we call napi_disable() on the receive queue's napi. In delayed refill_work, it also calls napi_disable() on the receive queue's napi. This can leads to deadlock when napi_disable() is called on

Re: [PATCH] virtio-net: disable delayed refill when pausing rx

2025-04-10 Thread Bui Quang Minh
On 4/9/25 13:44, Bui Quang Minh wrote: On 4/8/25 14:34, Jason Wang wrote: On Mon, Apr 7, 2025 at 10:27 AM Bui Quang Minh wrote: On 4/7/25 08:03, Xuan Zhuo wrote: On Fri,  4 Apr 2025 16:39:03 +0700, Bui Quang Minh wrote: When pausing rx (e.g. set up xdp, xsk pool, rx resize), we call

[PATCH] virtio-net: hold netdev_lock when pausing rx

2025-04-10 Thread Bui Quang Minh
NAPI enablement with netdev_lock()") Signed-off-by: Bui Quang Minh ---  drivers/net/virtio_net.c | 74 +---  1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7e4617216a4b..74bd1065c586

Re: [PATCH] virtio-net: hold netdev_lock when pausing rx

2025-04-10 Thread Bui Quang Minh
On 4/10/25 14:58, Michael S. Tsirkin wrote: On Thu, Apr 10, 2025 at 02:05:57PM +0700, Bui Quang Minh wrote: When pausing rx (e.g. set up xdp, xsk pool, rx resize), we call napi_disable() on the receive queue's napi. In delayed refill_work, it also calls napi_disable() on the receive qu

[PATCH] virtio-net: disable delayed refill when setting up xdp

2025-04-01 Thread Bui Quang Minh
es this by disabling future and cancelling all inflight delayed refill works before calling napi_disabled() in virtnet_xdp_set. Fixes: 4941d472bf95 ("virtio-net: do not reset during XDP set") Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 12 1 file changed, 12 inser

Re: [PATCH] virtio-net: disable delayed refill when pausing rx

2025-04-08 Thread Bui Quang Minh
On 4/8/25 14:34, Jason Wang wrote: On Mon, Apr 7, 2025 at 10:27 AM Bui Quang Minh wrote: On 4/7/25 08:03, Xuan Zhuo wrote: On Fri, 4 Apr 2025 16:39:03 +0700, Bui Quang Minh wrote: When pausing rx (e.g. set up xdp, xsk pool, rx resize), we call napi_disable() on the receive queue's

Re: [PATCH] virtio-net: disable delayed refill when pausing rx

2025-04-06 Thread Bui Quang Minh
On 4/7/25 08:03, Xuan Zhuo wrote: On Fri, 4 Apr 2025 16:39:03 +0700, Bui Quang Minh wrote: When pausing rx (e.g. set up xdp, xsk pool, rx resize), we call napi_disable() on the receive queue's napi. In delayed refill_work, it also calls napi_disable() on the receive queue's napi

[PATCH v5 1/3] selftests: net: move xdp_helper to net/lib

2025-04-24 Thread Bui Quang Minh
Move xdp_helper to net/lib to make it easier for other selftests to use the helper. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/drivers/net/Makefile | 2 -- tools/testing/selftests/drivers/net/queues.py | 4 ++-- tools/testing/selftests/net/lib

[PATCH v5 2/3] selftests: net: add flag to force zerocopy mode in xdp_helper

2025-04-24 Thread Bui Quang Minh
This commit adds an optional -z flag to xdp_helper. When this flag is provided, the XDP socket binding is forced to be in zerocopy mode. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/net/lib/xdp_helper.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions

[PATCH v5 3/3] selftests: net: add a virtio_net deadlock selftest

2025-04-24 Thread Bui Quang Minh
The selftest reproduces the deadlock scenario when binding/unbinding XDP program, XDP socket, rx ring resize on virtio_net interface. Signed-off-by: Bui Quang Minh --- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../selftests/drivers/net/hw/xsk_reconfig.py | 68 +++ 2

Re: [PATCH v4 4/4] selftests: net: add a virtio_net deadlock selftest

2025-04-23 Thread Bui Quang Minh
On 4/23/25 08:41, Jakub Kicinski wrote: On Thu, 17 Apr 2025 14:28:06 +0700 Bui Quang Minh wrote: The selftest reproduces the deadlock scenario when binding/unbinding XDP program, XDP socket, rx ring resize on virtio_net interface. Signed-off-by: Bui Quang Minh --- .../testing/selftests

Re: [PATCH] virtio-net: disable delayed refill when pausing rx

2025-04-10 Thread Bui Quang Minh
e lock. We can try request_ops_lock in -next ? Bui Quang Minh, could you add a selftest for this problem? See tools/testing/selftests/drivers/net/virtio_net/ You can re-use / extend the XSK helper from tools/testing/selftests/drivers/net/xdp_helper.c ? (move it to tools/testing/selftests/net/lib

[PATCH v2 1/3] virtio-net: disable delayed refill when pausing rx

2025-04-13 Thread Bui Quang Minh
use the rx. Fixes: 413f0271f396 ("net: protect NAPI enablement with netdev_lock()") Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 60 ++-- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/drivers/net/virtio_net.c b/driv

[PATCH v2 3/3] selftests: net: add a virtio_net deadlock selftest

2025-04-13 Thread Bui Quang Minh
The selftest reproduces the deadlock scenario when binding/unbinding XDP program, XDP socket, rx ring resize on virtio_net interface. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/Makefile | 2 +- .../selftests/drivers/net/virtio_net/Makefile | 2 + .../selftests

[PATCH v2 2/3] selftests: net: move xdp_helper to net/lib

2025-04-13 Thread Bui Quang Minh
Move xdp_helper to net/lib to make it easier for other selftests to use the helper. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/drivers/net/Makefile | 2 -- tools/testing/selftests/drivers/net/queues.py | 4 ++-- tools/testing/selftests/net/lib

[PATCH v2 0/3] virtio-net: disable delayed refill when pausing rx

2025-04-13 Thread Bui Quang Minh
and fixes up the virtnet_rx_resume to disable future and cancel all inflights delayed refill_work before calling napi_disable() to pause the rx. Version 2 changes: - Add selftest for deadlock scenario Thanks, Quang Minh. Bui Quang Minh (3): virtio-net: disable delayed refill when pausing rx

[PATCH v4 2/4] selftests: net: move xdp_helper to net/lib

2025-04-17 Thread Bui Quang Minh
Move xdp_helper to net/lib to make it easier for other selftests to use the helper. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/drivers/net/Makefile | 2 -- tools/testing/selftests/drivers/net/queues.py | 4 ++-- tools/testing/selftests/net/lib

[PATCH v4 1/4] virtio-net: disable delayed refill when pausing rx

2025-04-17 Thread Bui Quang Minh
use the rx. Fixes: 413f0271f396 ("net: protect NAPI enablement with netdev_lock()") Acked-by: Michael S. Tsirkin Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 69 +--- 1 file changed, 57 insertions(+), 12 deletions(-) diff

[PATCH v4 4/4] selftests: net: add a virtio_net deadlock selftest

2025-04-17 Thread Bui Quang Minh
The selftest reproduces the deadlock scenario when binding/unbinding XDP program, XDP socket, rx ring resize on virtio_net interface. Signed-off-by: Bui Quang Minh --- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../selftests/drivers/net/hw/virtio_net.py| 65 +++ 2

[PATCH v4 3/4] selftests: net: add flag to force zerocopy mode in xdp_helper

2025-04-17 Thread Bui Quang Minh
This commit adds an optional -z flag to xdp_helper. When this flag is provided, the XDP socket binding is forced to be in zerocopy mode. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/net/lib/xdp_helper.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff

Re: [PATCH v3 3/3] selftests: net: add a virtio_net deadlock selftest

2025-04-15 Thread Bui Quang Minh
On 4/16/25 11:27, Jakub Kicinski wrote: On Tue, 15 Apr 2025 14:43:41 +0700 Bui Quang Minh wrote: +def setup_xsk(cfg, xdp_queue_id = 0) -> bkg: +# Probe for support +xdp = cmd(f'{cfg.net_lib_dir / "xdp_helper"} - -', fail=False) +if xdp.ret == 255: +r

Re: [PATCH v3 3/3] selftests: net: add a virtio_net deadlock selftest

2025-04-16 Thread Bui Quang Minh
On 4/16/25 14:46, Jason Wang wrote: On Wed, Apr 16, 2025 at 2:54 PM Bui Quang Minh wrote: On 4/16/25 11:27, Jakub Kicinski wrote: On Tue, 15 Apr 2025 14:43:41 +0700 Bui Quang Minh wrote: +def setup_xsk(cfg, xdp_queue_id = 0) -> bkg: +# Probe for support +xdp = cmd(f'{cfg.net

[PATCH v4 0/4] virtio-net: disable delayed refill when pausing rx

2025-04-17 Thread Bui Quang Minh
w Version 3 changes: - Patch 1: refactor to avoid code duplication Version 2 changes: - Add selftest for deadlock scenario Thanks, Quang Minh. Bui Quang Minh (4): virtio-net: disable delayed refill when pausing rx selftests: net: move xdp_helper to net/lib selftests: net: add flag to forc

Re: [PATCH v4 4/4] selftests: net: add a virtio_net deadlock selftest

2025-04-24 Thread Bui Quang Minh
On 4/24/25 05:23, Jakub Kicinski wrote: On Wed, 23 Apr 2025 22:20:41 +0700 Bui Quang Minh wrote: I've tried to make the setup_xsk into each test. However, I've an issue that the XDP socket destruct waits for an RCU grace period as I see this sock's flag SOCK_RCU_FREE is set. So

[PATCH v5 0/3] virtio-net: disable delayed refill when pausing rx

2025-04-24 Thread Bui Quang Minh
changes: - Add force zerocopy mode to xdp_helper - Make virtio_net selftest use force zerocopy mode - Move virtio_net selftest to drivers/net/hw Version 3 changes: - Patch 1: refactor to avoid code duplication Version 2 changes: - Add selftest for deadlock scenario Thanks, Quang Minh. Bui Quang Minh

Re: [PATCH v5 0/3] virtio-net: disable delayed refill when pausing rx

2025-04-24 Thread Bui Quang Minh
On 4/25/25 08:34, Jakub Kicinski wrote: On Thu, 24 Apr 2025 17:47:13 +0700 Bui Quang Minh wrote: This only includes the selftest for virtio-net deadlock bug. The fix commit has been applied already. This conflicts with Joe's series slightly: https://lore.kernel.org/all/20250424002746.16

[PATCH v6 0/4] virtio-net: disable delayed refill when pausing rx

2025-04-25 Thread Bui Quang Minh
duplication Version 2 changes: - Add selftest for deadlock scenario Thanks, Quang Minh. Bui Quang Minh (4): selftests: net: move xdp_helper to net/lib selftests: net: add flag to force zerocopy mode in xdp_helper selftests: net: retry when bind returns EBUSY in xdp_helper selftests: net: add a

[PATCH v6 4/4] selftests: net: add a virtio_net deadlock selftest

2025-04-25 Thread Bui Quang Minh
The selftest reproduces the deadlock scenario when binding/unbinding XDP program, XDP socket, rx ring resize on virtio_net interface. Signed-off-by: Bui Quang Minh --- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../selftests/drivers/net/hw/xsk_reconfig.py | 60 +++ 2

[PATCH v6 3/4] selftests: net: retry when bind returns EBUSY in xdp_helper

2025-04-25 Thread Bui Quang Minh
When binding the XDP socket, we may get EBUSY because the deferred destructor of XDP socket in previous test has not been executed yet. If that is the case, just sleep and retry some times. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/net/lib/xdp_helper.c | 20

[PATCH v6 2/4] selftests: net: add flag to force zerocopy mode in xdp_helper

2025-04-25 Thread Bui Quang Minh
This commit adds an optional -z flag to xdp_helper. When this flag is provided, the XDP socket binding is forced to be in zerocopy mode. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/net/lib/xdp_helper.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions

[PATCH v6 1/4] selftests: net: move xdp_helper to net/lib

2025-04-25 Thread Bui Quang Minh
Move xdp_helper to net/lib to make it easier for other selftests to use the helper. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/drivers/net/.gitignore| 1 - tools/testing/selftests/drivers/net/Makefile | 1 - tools/testing/selftests/drivers/net

[PATCH v3 2/3] selftests: net: move xdp_helper to net/lib

2025-04-15 Thread Bui Quang Minh
Move xdp_helper to net/lib to make it easier for other selftests to use the helper. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/drivers/net/Makefile | 2 -- tools/testing/selftests/drivers/net/queues.py | 4 ++-- tools/testing/selftests/net/lib

[PATCH v3 0/3] virtio-net: disable delayed refill when pausing rx

2025-04-15 Thread Bui Quang Minh
and fixes up the virtnet_rx_resume to disable future and cancel all inflights delayed refill_work before calling napi_disable() to pause the rx. Version 3 changes: - Patch 1: refactor to avoid code duplication Version 2 changes: - Add selftest for deadlock scenario Thanks, Quang Minh. Bui Qua

[PATCH v3 3/3] selftests: net: add a virtio_net deadlock selftest

2025-04-15 Thread Bui Quang Minh
The selftest reproduces the deadlock scenario when binding/unbinding XDP program, XDP socket, rx ring resize on virtio_net interface. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/Makefile | 2 +- .../selftests/drivers/net/virtio_net/Makefile | 2 + .../selftests

[PATCH v3 1/3] virtio-net: disable delayed refill when pausing rx

2025-04-15 Thread Bui Quang Minh
use the rx. Fixes: 413f0271f396 ("net: protect NAPI enablement with netdev_lock()") Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 69 +--- 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio_net.c b/driv

[RFC PATCH net-next] virtio-net: support zerocopy multi buffer XDP in mergeable

2025-04-26 Thread Bui Quang Minh
Currently, in zerocopy mode with mergeable receive buffer, virtio-net does not support multi buffer but a single buffer only. This commit adds support for multi mergeable receive buffer in the zerocopy XDP path by utilizing XDP buffer with frags. Signed-off-by: Bui Quang Minh --- drivers/net

Re: [RFC PATCH net-next] virtio-net: support zerocopy multi buffer XDP in mergeable

2025-04-26 Thread Bui Quang Minh
On 4/26/25 15:27, Bui Quang Minh wrote: Currently, in zerocopy mode with mergeable receive buffer, virtio-net does not support multi buffer but a single buffer only. This commit adds support for multi mergeable receive buffer in the zerocopy XDP path by utilizing XDP buffer with frags. Signed

Re: [PATCH] virtio-net: disable delayed refill when setting up xdp

2025-04-03 Thread Bui Quang Minh
On 4/3/25 14:24, Paolo Abeni wrote: On 4/2/25 7:42 AM, Bui Quang Minh wrote: When setting up XDP for a running interface, we call napi_disable() on the receive queue's napi. In delayed refill_work, it also calls napi_disable() on the receive queue's napi. This can leads to dea

[PATCH] virtio-net: disable delayed refill when pausing rx

2025-04-04 Thread Bui Quang Minh
ind xsk for rx") Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 60 ++-- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7e4617216a4b..4361b91ccc64 100644 --- a/dr

Re: [PATCH] virtio-net: disable delayed refill when setting up xdp

2025-04-04 Thread Bui Quang Minh
On 4/3/25 17:43, Bui Quang Minh wrote: On 4/2/25 12:42, Bui Quang Minh wrote: When setting up XDP for a running interface, we call napi_disable() on the receive queue's napi. In delayed refill_work, it also calls napi_disable() on the receive queue's napi. This can leads to dea

[RFC PATCH net-next v2 1/2] virtio-net: support zerocopy multi buffer XDP in mergeable

2025-05-27 Thread Bui Quang Minh
Currently, in zerocopy mode with mergeable receive buffer, virtio-net does not support multi buffer but a single buffer only. This commit adds support for multi mergeable receive buffer in the zerocopy XDP path by utilizing XDP buffer with frags. Signed-off-by: Bui Quang Minh --- drivers/net

[RFC PATCH net-next v2 0/2] virtio-net: support zerocopy multi buffer XDP in mergeable

2025-05-27 Thread Bui Quang Minh
TU to test both single buffer and multi buffer XDP. Changes in RFC v2: - Return XDP_DROP when receiving multi-buffer XDP but BPF program does not support it - Add selftest - Link to RFC v1: https://lore.kernel.org/netdev/20250426082752.43222-1-minhquangbu...@gmail.com/ Thanks, Quang Minh. Bui Quang

[RFC PATCH net-next v2 2/2] selftests: net: add XDP socket tests for virtio-net

2025-05-27 Thread Bui Quang Minh
This adds a test to test the virtio-net rx when there is a XDP socket bound to it. There are tests for both copy mode and zerocopy mode, both cases when XDP program returns XDP_PASS and XDP_REDIRECT to a XDP socket. Signed-off-by: Bui Quang Minh --- .../selftests/drivers/net/hw/.gitignore

Re: [PATCH net] selftests: net: build net/lib dependency in all target

2025-05-29 Thread Bui Quang Minh
On 5/29/25 20:34, Simon Horman wrote: On Thu, May 29, 2025 at 06:04:17PM +0700, Bui Quang Minh wrote: On 5/29/25 17:32, Simon Horman wrote: On Thu, May 29, 2025 at 02:05:36PM +0700, Bui Quang Minh wrote: Currently, we only build net/lib dependency in install target. This commit moves that to

Re: [RFC PATCH net-next v2 1/2] virtio-net: support zerocopy multi buffer XDP in mergeable

2025-05-29 Thread Bui Quang Minh
On 5/29/25 12:59, Jason Wang wrote: On Wed, May 28, 2025 at 12:19 AM Bui Quang Minh wrote: Currently, in zerocopy mode with mergeable receive buffer, virtio-net does not support multi buffer but a single buffer only. This commit adds support for multi mergeable receive buffer in the zerocopy

Re: [RFC PATCH net-next v2 2/2] selftests: net: add XDP socket tests for virtio-net

2025-05-29 Thread Bui Quang Minh
On 5/29/25 18:18, Maciej Fijalkowski wrote: On Tue, May 27, 2025 at 11:19:04PM +0700, Bui Quang Minh wrote: This adds a test to test the virtio-net rx when there is a XDP socket bound to it. There are tests for both copy mode and zerocopy mode, both cases when XDP program returns XDP_PASS and

Re: [RFC PATCH net-next v2 1/2] virtio-net: support zerocopy multi buffer XDP in mergeable

2025-05-28 Thread Bui Quang Minh
On 5/28/25 23:44, ALOK TIWARI wrote: On 27-05-2025 21:49, Bui Quang Minh wrote: Currently, in zerocopy mode with mergeable receive buffer, virtio-net does not support multi buffer but a single buffer only. This commit adds support for multi mergeable receive buffer in the zerocopy XDP path by

[PATCH net] selftests: net: build net/lib dependency in all target

2025-05-29 Thread Bui Quang Minh
Currently, we only build net/lib dependency in install target. This commit moves that to all target so that net/lib is included in in-tree build and run_tests. Signed-off-by: Bui Quang Minh --- tools/testing/selftests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff

Re: [RFC PATCH net-next v2 2/2] selftests: net: add XDP socket tests for virtio-net

2025-05-28 Thread Bui Quang Minh
On 5/29/25 00:04, ALOK TIWARI wrote: On 27-05-2025 21:49, Bui Quang Minh wrote: +def main(): +    with NetDrvEpEnv(__file__, nsim_test=False) as cfg: +    cfg.bin_local = path.abspath(path.dirname(__file__) +    + "/../../../drivers/net/hw/xsk_re

Re: [PATCH net] selftests: net: build net/lib dependency in all target

2025-05-29 Thread Bui Quang Minh
On 5/29/25 17:32, Simon Horman wrote: On Thu, May 29, 2025 at 02:05:36PM +0700, Bui Quang Minh wrote: Currently, we only build net/lib dependency in install target. This commit moves that to all target so that net/lib is included in in-tree build and run_tests. Hi, The above describes what is

Re: [RFC PATCH net-next v2 2/2] selftests: net: add XDP socket tests for virtio-net

2025-05-31 Thread Bui Quang Minh
On 5/30/25 18:45, Maciej Fijalkowski wrote: On Thu, May 29, 2025 at 09:29:14PM +0700, Bui Quang Minh wrote: On 5/29/25 18:18, Maciej Fijalkowski wrote: On Tue, May 27, 2025 at 11:19:04PM +0700, Bui Quang Minh wrote: This adds a test to test the virtio-net rx when there is a XDP socket bound

[PATCH net v2] selftests: net: build net/lib dependency in all target

2025-05-30 Thread Bui Quang Minh
have net/lib included in net related selftests. Reviewed-by: Jakub Kicinski Signed-off-by: Bui Quang Minh --- Changes in v2: - Make the commit message clearer. tools/testing/selftests/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests

Re: [PATCH net v2] selftests: net: build net/lib dependency in all target

2025-05-30 Thread Bui Quang Minh
On 5/31/25 12:10, Bui Quang Minh wrote: We have the logic to include net/lib automatically for net related selftests. However, currently, this logic is only in install target which means only `make install` will have net/lib included. This commit moves the logic to all target so that all `make

[PATCH net v3] selftests: net: build net/lib dependency in all target

2025-06-01 Thread Bui Quang Minh
have net/lib included in net related selftests. Signed-off-by: Bui Quang Minh --- Changes in v3: - Don't remove INSTALL_DEP_TARGETS in install target so that net/lib is copied to INSTALL_PATH Changes in v2: - Make the commit message clearer. tools/testing/selftests/Makefile | 2 +- 1

Re: [PATCH net 1/2] virtio-net: xsk: rx: fix the frame's length check

2025-06-19 Thread Bui Quang Minh
On 6/19/25 09:11, Jakub Kicinski wrote: On Sun, 15 Jun 2025 22:13:32 +0700 Bui Quang Minh wrote: +/** + * buf_to_xdp() - convert the @buf context to xdp_buff + * @vi: virtnet_info struct + * @rq: the receive queue struct + * @buf: the xdp_buff pointer that is passed to

Re: [PATCH net v2 2/2] virtio-net: xsk: rx: move the xdp->data adjustment to buf_to_xdp()

2025-06-24 Thread Bui Quang Minh
On 6/24/25 17:17, Paolo Abeni wrote: On 6/21/25 4:49 PM, Bui Quang Minh wrote: This commit does not do any functional changes. It moves xdp->data adjustment for buffer other than first buffer to buf_to_xdp() helper so that the xdp_buff adjustment does not scatter over different functi

Re: [PATCH net v2 1/2] virtio-net: xsk: rx: fix the frame's length check

2025-06-24 Thread Bui Quang Minh
On 6/24/25 17:02, Paolo Abeni wrote: On 6/21/25 4:49 PM, Bui Quang Minh wrote: When calling buf_to_xdp, the len argument is the frame data's length without virtio header's length (vi->hdr_len). We check that len with xsk_pool_get_rx_frame_size() + vi->hdr_len to ens

Re: [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy

2025-06-13 Thread Bui Quang Minh
On 6/11/25 03:37, Jakub Kicinski wrote: On Tue, 10 Jun 2025 22:18:32 +0700 Bui Quang Minh wrote: Furthermore, we are in the zerocopy so we cannot linearize by allocating a large enough buffer to cover the whole frame then copy the frame data to it. That's not zerocopy anymore. Also, XDP s

[PATCH net v2 1/2] virtio-net: xsk: rx: fix the frame's length check

2025-06-21 Thread Bui Quang Minh
orrectly calculate the maximum frame's length. Fixes: a4e7ba702701 ("virtio_net: xsk: rx: support recv small mode") Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/net/

[PATCH net v2 0/2] virtio-net: xsk: rx: fix the frame's length check

2025-06-21 Thread Bui Quang Minh
s helper contains all logic to build xdp_buff and the tricky adjustment does not scatter over different functions. Version 2 changes: - Patch 1: fix kdoc Thanks, Quang Minh. Bui Quang Minh (2): virtio-net: xsk: rx: fix the frame's length check virtio-net: xsk: rx: move the xdp->data adjustme

[PATCH net v2 2/2] virtio-net: xsk: rx: move the xdp->data adjustment to buf_to_xdp()

2025-06-21 Thread Bui Quang Minh
This commit does not do any functional changes. It moves xdp->data adjustment for buffer other than first buffer to buf_to_xdp() helper so that the xdp_buff adjustment does not scatter over different functions. Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 16 ++--

[PATCH net 1/2] virtio-net: xsk: rx: fix the frame's length check

2025-06-15 Thread Bui Quang Minh
orrectly calculate the maximum frame's length. Fixes: a4e7ba702701 ("virtio_net: xsk: rx: support recv small mode") Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 30 ++ 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/driver

[PATCH net 2/2] virtio-net: xsk: rx: move the xdp->data adjustment to buf_to_xdp()

2025-06-15 Thread Bui Quang Minh
This commit does not do any functional changes. It moves xdp->data adjustment for buffer other than first buffer to buf_to_xdp() helper so that the xdp_buff adjustment does not scatter over different functions. Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 16 ++--

[PATCH net 0/2] virtio-net: xsk: rx: fix the frame's length check

2025-06-15 Thread Bui Quang Minh
s helper contains all logic to build xdp_buff and the tricky adjustment does not scatter over different functions. Thanks, Quang Minh. Bui Quang Minh (2): virtio-net: xsk: rx: fix the frame's length check virtio-net: xsk: rx: move the xdp->data adjustment to buf_to_xdp() drivers/net/v

[PATCH net 0/4] virtio-net: fixes for mergeable XDP receive path

2025-06-25 Thread Bui Quang Minh
lt; PAGE_SIZE. XDP does not have this restriction, so we can lift the restriction here and continue processing the frame. Thanks, Quang Minh. Bui Quang Minh (4): virtio-net: ensure the received length does not exceed allocated size virtio-net: remove redundant truesize check with PAGE_SIZE

[PATCH net 1/4] virtio-net: ensure the received length does not exceed allocated size

2025-06-25 Thread Bui Quang Minh
ned-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 27 ++- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index e53ba600605a..2a130a3e50ac 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/vi

[PATCH net 2/4] virtio-net: remove redundant truesize check with PAGE_SIZE

2025-06-25 Thread Bui Quang Minh
The truesize is guaranteed not to exceed PAGE_SIZE in get_mergeable_buf_len(). It is saved in mergeable context, which is not changeable by the host side, so the check in receive path is quite redundant. Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 7 +++ 1 file changed, 3

[PATCH net 3/4] virtio-net: create a helper to check received mergeable buffer's length

2025-06-25 Thread Bui Quang Minh
Currently, we have repeated code to check the received mergeable buffer's length with allocated size. This commit creates a helper to do that and converts current code to use it. Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 68 +--- 1

[PATCH net 4/4] virtio-net: allow more allocated space for mergeable XDP

2025-06-25 Thread Bui Quang Minh
ZE in that case and continue to process the frame. In my opinion, the current drop behavior is fine and expected so this commit is just an improvement not a bug fix. Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletion

Re: [PATCH net 3/4] virtio-net: create a helper to check received mergeable buffer's length

2025-06-26 Thread Bui Quang Minh
On 6/26/25 09:38, Jason Wang wrote: On Thu, Jun 26, 2025 at 12:10 AM Bui Quang Minh wrote: Currently, we have repeated code to check the received mergeable buffer's length with allocated size. This commit creates a helper to do that and converts current code to use it. Signed-off-by

Re: [RFC PATCH net-next v2 2/2] selftests: net: add XDP socket tests for virtio-net

2025-06-03 Thread Bui Quang Minh
On 6/2/25 22:55, Maciej Fijalkowski wrote: On Sat, May 31, 2025 at 03:51:57PM +0700, Bui Quang Minh wrote: On 5/30/25 18:45, Maciej Fijalkowski wrote: On Thu, May 29, 2025 at 09:29:14PM +0700, Bui Quang Minh wrote: On 5/29/25 18:18, Maciej Fijalkowski wrote: On Tue, May 27, 2025 at 11:19

Re: [RFC PATCH net-next v2 1/2] virtio-net: support zerocopy multi buffer XDP in mergeable

2025-06-03 Thread Bui Quang Minh
On 6/3/25 09:56, Jason Wang wrote: On Thu, May 29, 2025 at 8:28 PM Bui Quang Minh wrote: On 5/29/25 12:59, Jason Wang wrote: On Wed, May 28, 2025 at 12:19 AM Bui Quang Minh wrote: Currently, in zerocopy mode with mergeable receive buffer, virtio-net does not support multi buffer but a

[PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy

2025-06-03 Thread Bui Quang Minh
incorrect behavior. This commit instead returns XDP_DROP in that case. Fixes: 99c861b44eb1 ("virtio_net: xsk: rx: support recv merge mode") Cc: sta...@vger.kernel.org Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 11 --- 1 file changed, 8 insertions(+), 3 deletion

Re: [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy

2025-06-04 Thread Bui Quang Minh
On 6/4/25 07:37, Jason Wang wrote: On Tue, Jun 3, 2025 at 11:07 PM Bui Quang Minh wrote: In virtio-net, we have not yet supported multi-buffer XDP packet in zerocopy mode when there is a binding XDP program. However, in that case, when receiving multi-buffer XDP packet, we skip the XDP program

Re: [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy

2025-06-05 Thread Bui Quang Minh
On 6/5/25 18:03, Paolo Abeni wrote: On 6/3/25 5:06 PM, Bui Quang Minh wrote: In virtio-net, we have not yet supported multi-buffer XDP packet in zerocopy mode when there is a binding XDP program. However, in that case, when receiving multi-buffer XDP packet, we skip the XDP program and return

Re: [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy

2025-06-05 Thread Bui Quang Minh
On 6/4/25 23:55, Zvi Effron wrote: On Tue, Jun 3, 2025 at 8:09 AM Bui Quang Minh wrote: In virtio-net, we have not yet supported multi-buffer XDP packet in zerocopy mode when there is a binding XDP program. However, in that case, when receiving multi-buffer XDP packet, we skip the XDP program

Re: [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy

2025-06-06 Thread Bui Quang Minh
On 6/5/25 21:48, Jakub Kicinski wrote: On Thu, 5 Jun 2025 21:33:26 +0700 Bui Quang Minh wrote: On 6/5/25 18:03, Paolo Abeni wrote: On 6/3/25 5:06 PM, Bui Quang Minh wrote: In virtio-net, we have not yet supported multi-buffer XDP packet in zerocopy mode when there is a binding XDP program

Re: [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy

2025-06-10 Thread Bui Quang Minh
On 6/9/25 23:58, Jakub Kicinski wrote: On Fri, 6 Jun 2025 22:48:53 +0700 Bui Quang Minh wrote: But currently, if a multi-buffer packet arrives, it will not go through XDP program so it doesn't increase the stats but still goes to network stack. So I think it's not a correct behavio

[PATCH net-next] virtio-net: xsk: rx: move the xdp->data adjustment to buf_to_xdp()

2025-07-05 Thread Bui Quang Minh
This commit does not do any functional changes. It moves xdp->data adjustment for buffer other than first buffer to buf_to_xdp() helper so that the xdp_buff adjustment does not scatter over different functions. Signed-off-by: Bui Quang Minh --- drivers/net/virtio_net.c | 11 +-- 1 f

[PATCH net v2] virtio-net: fix received length check in big packets

2025-07-08 Thread Bui Quang Minh
. This commit fixes the received length check corresponding to that change. The current incorrect check can lead to NULL page pointer dereference in the below while loop when erroneous length is received. Fixes: 4959aebba8c0 ("virtio-net: use mtu size as buffer length for big packets") S

Re: [PATCH net v2] virtio-net: fix received length check in big packets

2025-07-08 Thread Bui Quang Minh
On 7/8/25 21:52, Parav Pandit wrote: From: Bui Quang Minh Sent: 08 July 2025 08:12 PM Since commit 4959aebba8c0 ("virtio-net: use mtu size as buffer length for big packets"), the allocated size for big packets is not MAX_SKB_FRAGS * PAGE_SIZE anymore but depends on negotiated MTU.

Re: [PATCH net] virtio-net: fix received length check in big packets

2025-07-08 Thread Bui Quang Minh
On 7/8/25 21:26, Bui Quang Minh wrote: On 7/7/25 10:48, Jason Wang wrote: On Sun, Jul 6, 2025 at 10:12 PM Bui Quang Minh wrote: Since commit 4959aebba8c0 ("virtio-net: use mtu size as buffer length for big packets"), the allocated size for big packets is not MAX_SKB_FRAGS * PAGE_SI

Re: [PATCH net] virtio-net: fix received length check in big packets

2025-07-08 Thread Bui Quang Minh
On 7/7/25 10:48, Jason Wang wrote: On Sun, Jul 6, 2025 at 10:12 PM Bui Quang Minh wrote: Since commit 4959aebba8c0 ("virtio-net: use mtu size as buffer length for big packets"), the allocated size for big packets is not MAX_SKB_FRAGS * PAGE_SIZE anymore but depends on negotiate

[PATCH net] virtio-net: fix received length check in big packets

2025-07-06 Thread Bui Quang Minh
. This commit fixes the received length check corresponding to that change. The current incorrect check can lead to NULL page pointer dereference in the below while loop when erroneous length is received. Fixes: 4959aebba8c0 ("virtio-net: use mtu size as buffer length for big packets") S

[PATCH net v2 0/3] virtio-net: fixes for mergeable XDP receive path

2025-06-30 Thread Bui Quang Minh
repeated code use the check_mergeable_len to check for received data length in mergeable mode Version 2 changes: - Move the check_mergeable_len helper definition to the patch 1. - Remove patch 4. Thanks, Quang Minh. Bui Quang Minh (3): virtio-net: ensure the received length does not exceed allocated

  1   2   >