Re: [PATCH bpf-next v1 0/2] ktls, sockmap: Fix missing uncharge operation and add selfttest
On 2025-04-25 13:59:56, Jiayuan Chen wrote: > Cong reported a warning when running ./test_sockmp: > https://lore.kernel.org/bpf/[email protected]/T/#t > > [ cut here ] > WARNING: CPU: 1 PID: 40 at net/ipv4/af_inet.c inet_sock_destruct+0x173/0x1d5 > Tainted: [W]=WARN > Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 > Workqueue: events sk_psock_destroy > RIP: 0010:inet_sock_destruct+0x173/0x1d5 > RSP: 0018:8880085cfc18 EFLAGS: 00010202 > RAX: 111003dbfc00 RBX: 88801edfe3e8 RCX: 822f5af4 > RDX: 0007 RSI: dc00 RDI: 88801edfe16c > RBP: 88801edfe184 R08: ed1003dbfc31 R09: > R10: 822f5ab7 R11: 88801edfe187 R12: 88801edfdec0 > R13: 888020376ac0 R14: 888020376ac0 R15: 888020376a60 > CS: 0010 DS: ES: CR0: 80050033 > CR2: 556365155830 CR3: 1d6aa000 CR4: 00350ef0 > Call Trace: > > __sk_destruct+0x46/0x222 > sk_psock_destroy+0x22f/0x242 > process_one_work+0x504/0x8a8 > ? process_one_work+0x39d/0x8a8 > ? __pfx_process_one_work+0x10/0x10 > ? worker_thread+0x44/0x2ae > ? __list_add_valid_or_report+0x83/0xea > ? srso_return_thunk+0x5/0x5f > ? __list_add+0x45/0x52 > process_scheduled_works+0x73/0x82 > worker_thread+0x1ce/0x2ae > > > When we specify apply_bytes, we divide the msg into multiple segments, > each with a length of 'send', and every time we send this part of the data > using tcp_bpf_sendmsg_redir(), we use sk_msg_return_zero() to uncharge the > memory of the specified 'send' size. > > However, if the first segment of data fails to send, for example, the > peer's buffer is full, we need to release all of the msg. When releasing > the msg, we haven't uncharged the memory of the subsequent segments. > > This modification does not make significant logical changes, but only > fills in the missing uncharge places. > > This issue has existed all along, until it was exposed after we added the > apply test in test_sockmap: > > commit 3448ad23b34e ("selftests/bpf: Add apply_bytes test to > test_txmsg_redir_wait_sndmem in test_sockmap") > > > Jiayuan Chen (2): > ktls, sockmap: Fix missing uncharge operation > selftests/bpf: Add test to cover sockmap with ktls For the series thanks Jiayuan for poking into the kTLS side. I doubt anyone has used kTLS+apply_bytes yet. Thanks. For me. Acked-by: John Fastabend
[PATCH bpf-next v1 0/2] ktls, sockmap: Fix missing uncharge operation and add selfttest
Cong reported a warning when running ./test_sockmp: https://lore.kernel.org/bpf/[email protected]/T/#t [ cut here ] WARNING: CPU: 1 PID: 40 at net/ipv4/af_inet.c inet_sock_destruct+0x173/0x1d5 Tainted: [W]=WARN Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.15.0-1 04/01/2014 Workqueue: events sk_psock_destroy RIP: 0010:inet_sock_destruct+0x173/0x1d5 RSP: 0018:8880085cfc18 EFLAGS: 00010202 RAX: 111003dbfc00 RBX: 88801edfe3e8 RCX: 822f5af4 RDX: 0007 RSI: dc00 RDI: 88801edfe16c RBP: 88801edfe184 R08: ed1003dbfc31 R09: R10: 822f5ab7 R11: 88801edfe187 R12: 88801edfdec0 R13: 888020376ac0 R14: 888020376ac0 R15: 888020376a60 CS: 0010 DS: ES: CR0: 80050033 CR2: 556365155830 CR3: 1d6aa000 CR4: 00350ef0 Call Trace: __sk_destruct+0x46/0x222 sk_psock_destroy+0x22f/0x242 process_one_work+0x504/0x8a8 ? process_one_work+0x39d/0x8a8 ? __pfx_process_one_work+0x10/0x10 ? worker_thread+0x44/0x2ae ? __list_add_valid_or_report+0x83/0xea ? srso_return_thunk+0x5/0x5f ? __list_add+0x45/0x52 process_scheduled_works+0x73/0x82 worker_thread+0x1ce/0x2ae When we specify apply_bytes, we divide the msg into multiple segments, each with a length of 'send', and every time we send this part of the data using tcp_bpf_sendmsg_redir(), we use sk_msg_return_zero() to uncharge the memory of the specified 'send' size. However, if the first segment of data fails to send, for example, the peer's buffer is full, we need to release all of the msg. When releasing the msg, we haven't uncharged the memory of the subsequent segments. This modification does not make significant logical changes, but only fills in the missing uncharge places. This issue has existed all along, until it was exposed after we added the apply test in test_sockmap: commit 3448ad23b34e ("selftests/bpf: Add apply_bytes test to test_txmsg_redir_wait_sndmem in test_sockmap") Jiayuan Chen (2): ktls, sockmap: Fix missing uncharge operation selftests/bpf: Add test to cover sockmap with ktls net/tls/tls_sw.c | 7 ++ .../selftests/bpf/prog_tests/sockmap_ktls.c | 76 +++ .../selftests/bpf/progs/test_sockmap_ktls.c | 10 +++ 3 files changed, 93 insertions(+) -- 2.47.1

