netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Wang Yufen <wangyufen@huawei.com>
Cc: john.fastabend@gmail.com, daniel@iogearbox.net,
	jakub@cloudflare.com, lmb@cloudflare.com, davem@davemloft.net,
	bpf@vger.kernel.org, edumazet@google.com,
	yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org,
	ast@kernel.org, andrii@kernel.org, kafai@fb.com,
	songliubraving@fb.com, yhs@fb.com, kpsingh@kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/4] bpf, sockmap: Fix memleak in sk_psock_queue_msg
Date: Sun, 27 Feb 2022 11:21:12 -0800	[thread overview]
Message-ID: <YhvPKB8O7ml5JSHQ@pop-os.localdomain> (raw)
In-Reply-To: <20220225014929.942444-2-wangyufen@huawei.com>

On Fri, Feb 25, 2022 at 09:49:26AM +0800, Wang Yufen wrote:
> If tcp_bpf_sendmsg is running during a tear down operation we may enqueue
> data on the ingress msg queue while tear down is trying to free it.
> 
>  sk1 (redirect sk2)                         sk2
>  -------------------                      ---------------
> tcp_bpf_sendmsg()
>  tcp_bpf_send_verdict()
>   tcp_bpf_sendmsg_redir()
>    bpf_tcp_ingress()
>                                           sock_map_close()
>                                            lock_sock()
>     lock_sock() ... blocking
>                                            sk_psock_stop
>                                             sk_psock_clear_state(psock, SK_PSOCK_TX_ENABLED);
>                                            release_sock(sk);
>     lock_sock()	
>     sk_mem_charge()
>     get_page()
>     sk_psock_queue_msg()
>      sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED);
>       drop_sk_msg()
>     release_sock()
> 
> While drop_sk_msg(), the msg has charged memory form sk by sk_mem_charge
> and has sg pages need to put. To fix we use sk_msg_free() and then kfee()
> msg.
> 

What about the other code path? That is, sk_psock_skb_ingress_enqueue().
I don't see skmsg is charged there.

Thanks.

  reply	other threads:[~2022-02-27 19:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25  1:49 [PATCH bpf-next 0/4] bpf, sockmap: Fix memleaks and issues of mem charge/uncharge Wang Yufen
2022-02-25  1:49 ` [PATCH bpf-next 1/4] bpf, sockmap: Fix memleak in sk_psock_queue_msg Wang Yufen
2022-02-27 19:21   ` Cong Wang [this message]
2022-03-01  1:49     ` wangyufen
2022-03-01  3:44       ` John Fastabend
2022-03-03  0:31       ` Cong Wang
2022-02-25  1:49 ` [PATCH bpf-next 2/4] bpf, sockmap: Fix memleak in tcp_bpf_sendmsg while sk msg is full Wang Yufen
2022-03-01  4:02   ` John Fastabend
2022-03-01  7:05     ` wangyufen
2022-02-25  1:49 ` [PATCH bpf-next 3/4] bpf, sockmap: Fix more uncharged while msg has more_data Wang Yufen
2022-03-01  4:20   ` John Fastabend
2022-02-25  1:49 ` [PATCH bpf-next 4/4] bpf, sockmap: Fix double uncharge the mem of sk_msg Wang Yufen
2022-03-01  4:11   ` John Fastabend
2022-03-01  7:24     ` wangyufen

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=YhvPKB8O7ml5JSHQ@pop-os.localdomain \
    --to=xiyou.wangcong@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=jakub@cloudflare.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lmb@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=wangyufen@huawei.com \
    --cc=yhs@fb.com \
    --cc=yoshfuji@linux-ipv6.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;
as well as URLs for NNTP newsgroup(s).