linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: George Kennedy <george.kennedy@oracle.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tun: avoid double free in tun_free_netdev
Date: Thu, 9 Dec 2021 15:26:45 -0500	[thread overview]
Message-ID: <4ed8cace-3b2a-8cb8-43d9-bba1c342a3a5@oracle.com> (raw)
In-Reply-To: <20211208155838.24556030@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>



On 12/8/2021 6:58 PM, Jakub Kicinski wrote:
> On Wed, 8 Dec 2021 11:44:02 -0500 George Kennedy wrote:
>>> It looks like a lot of the problem is duplicate unwind.
>>> Why does err_free_flow, err_free_stat etc unwinds need to exist if
>>> the free_netdev is going to do same thing.
>> Maybe instead do not call security_tun_dev_free_security(tun->security)
>> in err_free_flow if it's going to be done anyway in tun_free_netdev().
> That won't be good either. register_netdevice() has multiple failure
> modes, it may or may not call the destructor depending on where it
> fails. Either the stuff that destructor undoes needs to be moved to
> ndo_init (which is what destructor always pairs with), or you can check
> dev->reg_state. If dev->reg_state is NETREG_UNREGISTERING that means
> the destructor will be caller later.
>
> The ndo_init way is preferable, just cut and past the appropriate lines
> preceding registration into a ndo_init callback.
Thank you Jakub,

Looking at other ndo_init's to try and figure out how much before 
register_netdevice() should go in it.

George

      reply	other threads:[~2021-12-09 20:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 14:43 [PATCH] tun: avoid double free in tun_free_netdev George Kennedy
2021-12-08 15:40 ` Greg KH
2021-12-08 16:29   ` George Kennedy
2021-12-08 16:33     ` Greg KH
2021-12-08 16:36     ` Stephen Hemminger
2021-12-08 16:44       ` George Kennedy
2021-12-08 23:58         ` Jakub Kicinski
2021-12-09 20:26           ` George Kennedy [this message]

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=4ed8cace-3b2a-8cb8-43d9-bba1c342a3a5@oracle.com \
    --to=george.kennedy@oracle.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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).