[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <IA3PR11MB8986D77869E75AA14C8A793AE59FA@IA3PR11MB8986.namprd11.prod.outlook.com>
Date: Fri, 30 Jan 2026 07:40:49 +0000
From: "Loktionov, Aleksandr" <aleksandr.loktionov@...el.com>
To: "Oros, Petr" <poros@...hat.com>, "netdev@...r.kernel.org"
<netdev@...r.kernel.org>
CC: "Vecera, Ivan" <ivecera@...hat.com>, "Kitszel, Przemyslaw"
<przemyslaw.kitszel@...el.com>, Richard Cochran <richardcochran@...il.com>,
Eric Dumazet <edumazet@...gle.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, Andrew Lunn <andrew+netdev@...n.ch>, "Nguyen,
Anthony L" <anthony.l.nguyen@...el.com>, Simon Horman <horms@...nel.org>,
Mateusz Polchlopek <mateusz.polchlopek@...el.com>, "Keller, Jacob E"
<jacob.e.keller@...el.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
<pabeni@...hat.com>, "David S. Miller" <davem@...emloft.net>,
"intel-wired-lan@...ts.osuosl.org" <intel-wired-lan@...ts.osuosl.org>
Subject: RE: [Intel-wired-lan] [PATCH net] iavf: fix PTP use-after-free during
reset
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@...osl.org> On Behalf
> Of Petr Oros
> Sent: Thursday, January 29, 2026 10:57 AM
> To: netdev@...r.kernel.org
> Cc: Vecera, Ivan <ivecera@...hat.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@...el.com>; Richard Cochran
> <richardcochran@...il.com>; Eric Dumazet <edumazet@...gle.com>; linux-
> kernel@...r.kernel.org; Andrew Lunn <andrew+netdev@...n.ch>; Nguyen,
> Anthony L <anthony.l.nguyen@...el.com>; Simon Horman
> <horms@...nel.org>; Mateusz Polchlopek <mateusz.polchlopek@...el.com>;
> Keller, Jacob E <jacob.e.keller@...el.com>; Jakub Kicinski
> <kuba@...nel.org>; Paolo Abeni <pabeni@...hat.com>; David S. Miller
> <davem@...emloft.net>; intel-wired-lan@...ts.osuosl.org
> Subject: [Intel-wired-lan] [PATCH net] iavf: fix PTP use-after-free
> during reset
>
> Commit 7c01dbfc8a1c5f ("iavf: periodically cache PHC time") introduced
> a worker to cache PHC time, but failed to stop it during reset or
> disable.
>
> This creates a race condition where `iavf_reset_task()` or
> `iavf_disable_vf()` free adapter resources (AQ) while the worker is
> still running. If the worker triggers `iavf_queue_ptp_cmd()` during
> teardown, it accesses freed memory/locks, leading to a crash.
>
> Fix this by calling `iavf_ptp_release()` before tearing down the
> adapter.
> This ensures `ptp_clock_unregister()` synchronously cancels the worker
> and cleans up the chardev before the backing resources are destroyed.
>
> Fixes: 7c01dbfc8a1c5f ("iavf: periodically cache PHC time")
> Signed-off-by: Petr Oros <poros@...hat.com>
> ---
> drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c
> b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 4b0fc8f354bc90..0dd58ce5a53ab1 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -3025,6 +3025,8 @@ static void iavf_disable_vf(struct iavf_adapter
> *adapter)
>
> adapter->flags |= IAVF_FLAG_PF_COMMS_FAILED;
>
> + iavf_ptp_release(adapter);
> +
> /* We don't use netif_running() because it may be true prior to
> * ndo_open() returning, so we can't assume it means all our
> open
> * tasks have finished, since we're not holding the rtnl_lock
> here.
> @@ -3200,6 +3202,8 @@ static void iavf_reset_task(struct work_struct
> *work)
> iavf_change_state(adapter, __IAVF_RESETTING);
> adapter->flags &= ~IAVF_FLAG_RESET_PENDING;
>
> + iavf_ptp_release(adapter);
> +
> /* free the Tx/Rx rings and descriptors, might be better to
> just
> * re-use them sometime in the future
> */
> --
> 2.52.0
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@...el.com>
Powered by blists - more mailing lists