From: Jason Wang <jasowang@redhat.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
Dmitry Vyukov <dvyukov@google.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Patch net v2] tun: fix a memory leak for tfile->tx_array
Date: Mon, 15 Jan 2018 15:07:41 +0800 [thread overview]
Message-ID: <5ac38ff9-af8d-c1c3-fa08-764e2e5491cf@redhat.com> (raw)
In-Reply-To: <CAM_iQpXv=ihuqPWimLyEiA1kQH1fn7yxc_kK=Uu_dTnGTsquZA@mail.gmail.com>
On 2018年01月14日 01:31, Cong Wang wrote:
> On Thu, Jan 11, 2018 at 2:16 AM, Jason Wang <jasowang@redhat.com> wrote:
>> It looks to me what is actual missed is the cleanups tun_detach_all(). For
>> me the only case that could leak is
>>
>> open
>> attach
>> ip link del link dev tap0
>> close or another set_iff()
>>
>> So in this case, clean during close is not sufficient since it could be
>> attached to another device.
> In this case, close() still calls tun_detach() with clean=true, so
> with my patch, the tx_array is still cleaned. What am I missing here?
> Are you implying clean=true is not sufficient?
Consider the corner case:
1) open
2) tun_set_iff() (which calls tun_attach to initialize skb_array)
3) ip link del link dev tap0 (which calls tun_detach_all())
4) tun_set_iff() (current codes does not forbid this and it will
allocate skb array again)
Consider the skb array was only initialized when attach it to a real
device, we should do the cleanup when we detach it from a device which
happens on two places:
- actively: close to an tun fd (__tun_deatch())
- passively: tun device was destroyed (tun_detach_all())
Thanks
next prev parent reply other threads:[~2018-01-15 7:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 18:51 [Patch net v2] tun: fix a memory leak for tfile->tx_array Cong Wang
2018-01-11 10:16 ` Jason Wang
2018-01-13 17:31 ` Cong Wang
2018-01-15 7:07 ` Jason Wang [this message]
2018-01-15 19:36 ` Cong Wang
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=5ac38ff9-af8d-c1c3-fa08-764e2e5491cf@redhat.com \
--to=jasowang@redhat.com \
--cc=dvyukov@google.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/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).