[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230613200150.361bc462@kernel.org>
Date: Tue, 13 Jun 2023 20:01:50 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Fedor Pchelkin <pchelkin@...ras.ru>
Cc: "David S. Miller" <davem@...emloft.net>,
Sabrina Dubroca <sd@...asysnail.net>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, Raed Salem <raeds@...dia.com>,
Lior Nahmanson <liorna@...dia.com>,
Saeed Mahameed <saeedm@...dia.com>,
Hannes Frederic Sowa <hannes@...essinduktion.org>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
lvc-project@...uxtesting.org
Subject: Re: [PATCH] net: macsec: fix double free of percpu stats
On Tue, 13 Jun 2023 22:22:20 +0300 Fedor Pchelkin wrote:
> Inside macsec_add_dev() we free percpu macsec->secy.tx_sc.stats and
> macsec->stats on some of the memory allocation failure paths. However, the
> net_device is already registered to that moment: in macsec_newlink(), just
> before calling macsec_add_dev(). This means that during unregister process
> its priv_destructor - macsec_free_netdev() - will be called and will free
> the stats again.
>
> Remove freeing percpu stats inside macsec_add_dev() because
> macsec_free_netdev() will correctly free the already allocated ones. The
> pointers to unallocated stats stay NULL, and free_percpu() treats that
> correctly.
What prevents the device from being opened and used before
macsec_add_dev() has finished? I think we need a fix which
would move this code before register_netdev(), instead :(
--
pw-bot: cr
Powered by blists - more mailing lists