提交 820ed3fb 编写于 作者: J John Fastabend 提交者: Daniel Borkmann

bpf: sockmap, free memory on sock close with cork data

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: NJohn Fastabend <john.fastabend@gmail.com>
Fixes: 91843d54 ("bpf: sockmap, add msg_cork_bytes() helper")
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
上级 4608f064
...@@ -211,6 +211,12 @@ static void bpf_tcp_close(struct sock *sk, long timeout) ...@@ -211,6 +211,12 @@ static void bpf_tcp_close(struct sock *sk, long timeout)
close_fun = psock->save_close; close_fun = psock->save_close;
write_lock_bh(&sk->sk_callback_lock); 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_for_each_entry_safe(md, mtmp, &psock->ingress, list) {
list_del(&md->list); list_del(&md->list);
free_start_sg(psock->sock, md); free_start_sg(psock->sock, md);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册