[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a7788a20-3be8-b3e3-2c19-ca2d7d18e238@huawei.com>
Date: Fri, 4 Mar 2022 14:51:18 +0800
From: wangyufen <wangyufen@...wei.com>
To: Cong Wang <xiyou.wangcong@...il.com>
CC: <john.fastabend@...il.com>, <daniel@...earbox.net>,
<jakub@...udflare.com>, <lmb@...udflare.com>,
<davem@...emloft.net>, <edumazet@...gle.com>,
<yoshfuji@...ux-ipv6.org>, <dsahern@...nel.org>, <kuba@...nel.org>,
<ast@...nel.org>, <andrii@...nel.org>, <kafai@...com>,
<songliubraving@...com>, <yhs@...com>, <kpsingh@...nel.org>,
<netdev@...r.kernel.org>, <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf-next v2 2/4] bpf, sockmap: Fix memleak in
tcp_bpf_sendmsg while sk msg is full
在 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.
> .
Powered by blists - more mailing lists