Message ID | 20220302022755.3876705-3-wangyufen@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf, sockmap: Fix memleaks and issues of mem charge/uncharge | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest-bpf-next-PR | success | PR summary |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/cc_maintainers | success | CCed 17 of 17 maintainers |
netdev/build_clang | success | Errors and warnings before: 18 this patch: 18 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 7 this patch: 7 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 11 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
bpf/vmtest-bpf-next | success | VM_Test |
On Wed, Mar 02, 2022 at 10:27:53AM +0800, Wang Yufen wrote: > diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c > index 9b9b02052fd3..ac9f491cc139 100644 > --- a/net/ipv4/tcp_bpf.c > +++ b/net/ipv4/tcp_bpf.c > @@ -421,8 +421,10 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) > osize = msg_tx->sg.size; > err = sk_msg_alloc(sk, msg_tx, msg_tx->sg.size + copy, msg_tx->sg.end - 1); > if (err) { > - if (err != -ENOSPC) > + if (err != -ENOSPC) { > + sk_msg_trim(sk, msg_tx, osize); > goto wait_for_memory; Is it a good idea to handle this logic inside sk_msg_alloc()?
在 2022/3/3 8:48, Cong Wang 写道: > On Wed, Mar 02, 2022 at 10:27:53AM +0800, Wang Yufen wrote: >> diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c >> index 9b9b02052fd3..ac9f491cc139 100644 >> --- a/net/ipv4/tcp_bpf.c >> +++ b/net/ipv4/tcp_bpf.c >> @@ -421,8 +421,10 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) >> osize = msg_tx->sg.size; >> err = sk_msg_alloc(sk, msg_tx, msg_tx->sg.size + copy, msg_tx->sg.end - 1); >> if (err) { >> - if (err != -ENOSPC) >> + if (err != -ENOSPC) { >> + sk_msg_trim(sk, msg_tx, osize); >> goto wait_for_memory; > Is it a good idea to handle this logic inside sk_msg_alloc()? Yes, I think you're right. Other call paths of sk_msg_alloc() have the similar problem, such as tls_sw_sendmsg(), will do in v3. Thanks. > .
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 9b9b02052fd3..ac9f491cc139 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -421,8 +421,10 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) osize = msg_tx->sg.size; err = sk_msg_alloc(sk, msg_tx, msg_tx->sg.size + copy, msg_tx->sg.end - 1); if (err) { - if (err != -ENOSPC) + if (err != -ENOSPC) { + sk_msg_trim(sk, msg_tx, osize); goto wait_for_memory; + } enospc = true; copy = msg_tx->sg.size - osize; }