From: John Fastabend <john.fastabend@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: [bpf-next PATCH 1/4] bpf: sockmap, free memory on sock close with cork data
Date: Sun, 01 Apr 2018 08:00:54 -0700 [thread overview]
Message-ID: <20180401150054.24727.78359.stgit@john-Precision-Tower-5810> (raw)
In-Reply-To: <20180401145728.24727.706.stgit@john-Precision-Tower-5810>
If a socket with pending cork data is closed we do not return the
memory to the socket until the garbage collector free's the psock
structure. The garbage collector though can run after the sock has
completed its close operation. If this ordering happens the sock code
will through a WARN_ON because there is still outstanding memory
accounted to the sock.
To resolve this ensure we return memory to the sock when a socket
is closed.
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Fixes: 91843d540a13 ("bpf: sockmap, add msg_cork_bytes() helper")
---
kernel/bpf/sockmap.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c
index d2bda5a..8ddf326 100644
--- a/kernel/bpf/sockmap.c
+++ b/kernel/bpf/sockmap.c
@@ -211,6 +211,12 @@ static void bpf_tcp_close(struct sock *sk, long timeout)
close_fun = psock->save_close;
write_lock_bh(&sk->sk_callback_lock);
+ if (psock->cork) {
+ free_start_sg(psock->sock, psock->cork);
+ kfree(psock->cork);
+ psock->cork = NULL;
+ }
+
list_for_each_entry_safe(md, mtmp, &psock->ingress, list) {
list_del(&md->list);
free_start_sg(psock->sock, md);
next prev parent reply other threads:[~2018-04-01 15:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-01 15:00 [bpf-next PATCH 0/4] Sockmap Updates John Fastabend
2018-04-01 15:00 ` John Fastabend [this message]
2018-04-12 13:13 ` [bpf-next PATCH 1/4] bpf: sockmap, free memory on sock close with cork data Simon Horman
2018-04-01 15:00 ` [bpf-next PATCH 2/4] bpf: sockmap, duplicates release calls may NULL sk_prot John Fastabend
2018-04-01 15:01 ` [bpf-next PATCH 3/4] bpf: sockmap, refactor sockmap routines to work with hashmap John Fastabend
2018-04-23 6:32 ` [lkp-robot] [bpf] 4f7b25baf0: kernel_selftests.bpf.test_maps.fail kernel test robot
2018-04-23 9:41 ` Daniel Borkmann
2018-04-01 15:01 ` [bpf-next PATCH 4/4] bpf: sockmap, add hash map support John Fastabend
2018-04-02 15:54 ` Alexei Starovoitov
2018-04-02 17:53 ` John Fastabend
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180401150054.24727.78359.stgit@john-Precision-Tower-5810 \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox