]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iavf: fix PTP use-after-free during reset
authorPetr Oros <poros@redhat.com>
Thu, 29 Jan 2026 09:57:23 +0000 (10:57 +0100)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 10 Mar 2026 16:08:31 +0000 (09:08 -0700)
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@redhat.com>
Reviewed-by: Ivan Vecera <ivecera@redhat.com>
Acked-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/iavf/iavf_main.c

index 86c1964f42e10198f7e4375bda0272f216f19acc..c7abd3331e0345b197f8756001024753768cd52f 100644 (file)
@@ -3036,6 +3036,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.
@@ -3211,6 +3213,8 @@ continue_reset:
        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
         */