ice: Fix PTP NULL pointer dereference during VSI rebuild
Subsystems (3)
PATCH 1/1 ice: Fix PTP NULL pointer dereference during VSI rebuild
Fix race condition where PTP periodic work runs while VSI is being rebuilt, accessing NULL vsi->rx_rings.
The sequence was:
1. ice_ptp_prepare_for_reset() cancels PTP work
2. ice_ptp_rebuild() immediately queues PTP work
3. VSI rebuild happens AFTER ice_ptp_rebuild()
4. PTP work runs and accesses NULL vsi->rx_rings
Fix: Keep PTP work cancelled during rebuild, only queue it after VSI rebuild completes in ice_rebuild().
Added ice_ptp_queue_work() helper function to encapsulate the logic for queuing PTP work, ensuring it's only queued when PTP is supported and the state is ICE_PTP_READY.
Error log:
[ 121.392544] ice 0000:60:00.1: PTP reset successful [ 121.392692] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 121.392712] #PF: supervisor read access in kernel mode [ 121.392720] #PF: error_code(0x0000) - not-present page [ 121.392727] PGD 0 [ 121.392734] Oops: Oops: 0000 [#1] SMP NOPTI [ 121.392746] CPU: 8 UID: 0 PID: 1005 Comm: ice-ptp-0000:60 Tainted: G S 6.19.0-rc6+ #4 PREEMPT(voluntary) [ 121.392761] Tainted: [S]=CPU_OUT_OF_SPEC [ 121.392773] RIP: 0010:ice_ptp_update_cached_phctime+0xbf/0x150 [ice] [ 121.393042] Call Trace: [ 121.393047] <TASK> [ 121.393055] ice_ptp_periodic_work+0x69/0x180 [ice] [ 121.393202] kthread_worker_fn+0xa2/0x260 [ 121.393216] ? __pfx_ice_ptp_periodic_work+0x10/0x10 [ice] [ 121.393359] ? __pfx_kthread_worker_fn+0x10/0x10 [ 121.393371] kthread+0x10d/0x230 [ 121.393382] ? __pfx_kthread+0x10/0x10 [ 121.393393] ret_from_fork+0x273/0x2b0 [ 121.393407] ? __pfx_kthread+0x10/0x10 [ 121.393417] ret_from_fork_asm+0x1a/0x30 [ 121.393432] </TASK>
--- drivers/net/ethernet/intel/ice/ice_main.c | 3 +++ drivers/net/ethernet/intel/ice/ice_ptp.c | 26 ++++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_ptp.h | 5 +++++ 3 files changed, 29 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +3 -0
@@ -7814,6 +7814,9 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)/* Restore timestamp mode settings after VSI rebuild */ ice_ptp_restore_timestamp_mode (pf); + +/* Start PTP periodic work after VSI is fully rebuilt */ +ice_ptp_queue_work (pf);return ; err_vsi_rebuild:
drivers/net/ethernet/intel/ice/ice_ptp.c +21 -5
@@ -2817,6 +2817,20 @@ static void ice_ptp_periodic_work(struct kthread_work *work) msecs_to_jiffies(err ? 10 : 500)); } +/** +* ice_ptp_queue_work - Queue PTP periodic work for a PF +* @pf: Board private structure +* +* Helper function to queue PTP periodic work after VSI rebuild completes. +* This ensures that PTP work only runs when VSI structures are ready. +*/ +void ice_ptp_queue_work (struct ice_pf *pf) +{ +if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags) && + pf->ptp.state ==ICE_PTP_READY ) +kthread_queue_delayed_work (pf->ptp.kworker, &pf->ptp.work,0 ); +} +/** * ice_ptp_prepare_rebuild_sec - Prepare second NAC for PTP reset or rebuild * @pf: Board private structure
@@ -2835,10 +2849,15 @@ static void ice_ptp_prepare_rebuild_sec(struct ice_pf *pf, bool rebuild,struct ice_pf *peer_pf =ptp_port_to_pf (port);if (!ice_is_primary (&peer_pf->hw)) { -if (rebuild) +if (rebuild) { +/* TODO: When implementing rebuild=true: +* 1. Ensure secondary PFs' VSIs are rebuilt +* 2. Call ice_ptp_queue_work(peer_pf) after VSI rebuild +*/ ice_ptp_rebuild (peer_pf, reset_type); -else + }else {ice_ptp_prepare_for_reset (peer_pf, reset_type); + } } } }
@@ -2984,9 +3003,6 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) ptp->state =ICE_PTP_READY ; -/* Start periodic work going */ -kthread_queue_delayed_work (ptp->kworker, &ptp->work,0 ); -dev_info (ice_pf_to_dev (pf),"PTP reset successful\n" );return ;
drivers/net/ethernet/intel/ice/ice_ptp.h +5 -0
@@ -317,6 +317,7 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf,void ice_ptp_init (struct ice_pf *pf);void ice_ptp_release (struct ice_pf *pf);void ice_ptp_link_change (struct ice_pf *pf,bool linkup); +void ice_ptp_queue_work (struct ice_pf *pf);#else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */ static inline int ice_ptp_hwtstamp_get(struct net_device *netdev,
@@ -383,6 +384,10 @@ static inline void ice_ptp_link_change(struct ice_pf *pf, bool linkup) { } +static inline void ice_ptp_queue_work (struct ice_pf *pf) +{ +} +static inline int ice_ptp_clock_index (struct ice_pf *pf) {return -1 ;
Signature · 1 line
2.43.0
Quoted 113 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Aaron Ma via Intel-wired-lan
Sent: Wednesday, January 21, 2026 8:51 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH] ice: Fix PTP NULL pointer dereference during VSI rebuildFix race condition where PTP periodic work runs while VSI is being rebuilt, accessing NULL
vsi->rx_rings.The sequence was:
1.ice_ptp_prepare_for_reset()cancels PTP work 2.ice_ptp_rebuild()immediately queues PTP work 3. VSI rebuild happens AFTERice_ptp_rebuild()4. PTP work runs and accesses NULLvsi->rx_ringsFix: Keep PTP work cancelled during rebuild, only queue it after VSI rebuild completes in
ice_rebuild().Added
ice_ptp_queue_work()helper function to encapsulate the logic for queuing PTP work, ensuring it's only queued when PTP is supported and the state isICE_PTP_READY.Error log:
[ 121.392544] ice 0000:60:00.1: PTP reset successful [ 121.392692] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 121.392712] #PF: supervisor read access in kernel mode [ 121.392720] #PF: error_code(0x0000) - not-present page [ 121.392727] PGD 0 [ 121.392734] Oops: Oops: 0000 [#1] SMP NOPTI [ 121.392746] CPU: 8 UID: 0 PID: 1005 Comm: ice-ptp-0000:60 Tainted: G S 6.19.0-rc6+ #4 PREEMPT(voluntary) [ 121.392761] Tainted: [S]=CPU_OUT_OF_SPEC [ 121.392773] RIP: 0010:ice_ptp_update_cached_phctime+0xbf/0x150 [ice] [ 121.393042] Call Trace: [ 121.393047] <TASK> [ 121.393055] ice_ptp_periodic_work+0x69/0x180 [ice] [ 121.393202] kthread_worker_fn+0xa2/0x260 [ 121.393216] ? __pfx_ice_ptp_periodic_work+0x10/0x10 [ice] [ 121.393359] ? __pfx_kthread_worker_fn+0x10/0x10 [ 121.393371] kthread+0x10d/0x230 [ 121.393382] ? __pfx_kthread+0x10/0x10 [ 121.393393] ret_from_fork+0x273/0x2b0 [ 121.393407] ? __pfx_kthread+0x10/0x10 [ 121.393417] ret_from_fork_asm+0x1a/0x30 [ 121.393432] </TASK>Fixes 803bef817807d ("ice: factor out ice_ptp_rebuild_owner()")Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 3 +++ drivers/net/ethernet/intel/ice/ice_ptp.c | 26 ++++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_ptp.h | 5 +++++ 3 files changed, 29 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +3
-0@@ -7814,6 +7814,9 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)/* Restore timestamp mode settings after VSI rebuild */ ice_ptp_restore_timestamp_mode (pf ); + +/* Start PTP periodic work after VSI is fully rebuilt */ +ice_ptp_queue_work (pf);return ;
err_vsi_rebuild:drivers/net/ethernet/intel/ice/ice_ptp.c +5
-0@@ -2817,6 +2817,20 @@ static void ice_ptp_periodic_work(struct kthread_work *work) msecs_to_jiffies(err ? 10 : 500)); } +/** +* ice_ptp_queue_work - Queue PTP periodic work for a PF +* @pf: Board private structure +* +* Helper function to queue PTP periodic work after VSI rebuild completes.
+ * This ensures that PTP work only runs when VSI structures are ready.
+ */drivers/net/ethernet/intel/ice/ice_ptp.c +4
-0+void ice_ptp_queue_work (struct ice_pf *pf) { +if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags) && + pf->ptp.state ==ICE_PTP_READY ) + kthread_queue_delayed_work(pf->ptp.kworker, &pf-Quoted 1 line
ptp.work, 0); }
+
/**
*ice_ptp_prepare_rebuild_sec- Prepare second NAC for PTP reset or
rebuild
* @pf: Board private structuredrivers/net/ethernet/intel/ice/ice_ptp.c +3
-1@@ -2835,10 +2849,15 @@ static void ice_ptp_prepare_rebuild_sec(struct ice_pf *pf, bool rebuild, struct ice_pf *peer_pf = ptp_port_to_pf(port);if (!ice_is_primary (&peer_pf->hw)) { -if (rebuild) +if (rebuild) { +/* TODO: When implementing rebuild=true: +* 1. Ensure secondary PFs' VSIs are rebuilt
drivers/net/ethernet/intel/ice/ice_ptp.c +1
-0+* 2. Call ice_ptp_queue_work(peer_pf) after VSI rebuild
drivers/net/ethernet/intel/ice/ice_ptp.c
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_ptp.c +1
-0+*/
Shouldn't we resolve all TODOs before merging?
Quoted 42 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1
-1ice_ptp_rebuild (peer_pf, reset_type); - else + }else { ice_ptp_prepare_for_reset(peer_pf,
reset_type);drivers/net/ethernet/intel/ice/ice_ptp.c +1
-3+ } } } }@@ -2984,9 +3003,6 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) ptp->state = ICE_PTP_READY; -/* Start periodic work going */ -kthread_queue_delayed_work (ptp->kworker, &ptp->work,0 ); -dev_info (ice_pf_to_dev (pf),"PTP reset successful\n" );return ;drivers/net/ethernet/intel/ice/ice_ptp.h +0
-0@@ -317,6 +317,7 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf,void
ice_ptp_init(struct ice_pf *pf); voidice_ptp_release(struct ice_pf *pf); voidice_ptp_link_change(struct ice_pf *pf, bool linkup);
+voidice_ptp_queue_work(struct ice_pf *pf);
#else /*IS_ENABLED(CONFIG_PTP_1588_CLOCK)*/static inline int ice_ptp_hwtstamp_get(struct
net_device*netdev, @@
-383,6 +384,10 @@ static inline voidice_ptp_link_change(struct ice_pf *pf, bool linkup){ }drivers/net/ethernet/intel/ice/ice_ptp.h +2
-1+static inline void ice_ptp_queue_work (struct ice_pf *pf) { } +static inline int ice_ptp_clock_index (struct ice_pf *pf) {return -1 ; --2.43.0
Quoted 106 lines · Aleksandr
Quoted 106 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Aaron Ma via Intel-wired-lan
Sent: Wednesday, January 21, 2026 8:51 AM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH] ice: Fix PTP NULL pointer dereference during VSI rebuildFix race condition where PTP periodic work runs while VSI is being rebuilt, accessing NULL
vsi->rx_rings.The sequence was:
1.ice_ptp_prepare_for_reset()cancels PTP work 2.ice_ptp_rebuild()immediately queues PTP work 3. VSI rebuild happens AFTERice_ptp_rebuild()4. PTP work runs and accesses NULLvsi->rx_ringsFix: Keep PTP work cancelled during rebuild, only queue it after VSI rebuild completes in
ice_rebuild().Added
ice_ptp_queue_work()helper function to encapsulate the logic for queuing PTP work, ensuring it's only queued when PTP is supported and the state isICE_PTP_READY.Error log:
[ 121.392544] ice 0000:60:00.1: PTP reset successful [ 121.392692] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 121.392712] #PF: supervisor read access in kernel mode [ 121.392720] #PF: error_code(0x0000) - not-present page [ 121.392727] PGD 0 [ 121.392734] Oops: Oops: 0000 [#1] SMP NOPTI [ 121.392746] CPU: 8 UID: 0 PID: 1005 Comm: ice-ptp-0000:60 Tainted: G S 6.19.0-rc6+ #4 PREEMPT(voluntary) [ 121.392761] Tainted: [S]=CPU_OUT_OF_SPEC [ 121.392773] RIP: 0010:ice_ptp_update_cached_phctime+0xbf/0x150 [ice] [ 121.393042] Call Trace: [ 121.393047] <TASK> [ 121.393055] ice_ptp_periodic_work+0x69/0x180 [ice] [ 121.393202] kthread_worker_fn+0xa2/0x260 [ 121.393216] ? __pfx_ice_ptp_periodic_work+0x10/0x10 [ice] [ 121.393359] ? __pfx_kthread_worker_fn+0x10/0x10 [ 121.393371] kthread+0x10d/0x230 [ 121.393382] ? __pfx_kthread+0x10/0x10 [ 121.393393] ret_from_fork+0x273/0x2b0 [ 121.393407] ? __pfx_kthread+0x10/0x10 [ 121.393417] ret_from_fork_asm+0x1a/0x30 [ 121.393432] </TASK>Fixes 803bef817807d ("ice: factor out ice_ptp_rebuild_owner()")Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 3 +++ drivers/net/ethernet/intel/ice/ice_ptp.c | 26 ++++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_ptp.h | 5 +++++ 3 files changed, 29 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +3
-0@@ -7814,6 +7814,9 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)/* Restore timestamp mode settings after VSI rebuild */ ice_ptp_restore_timestamp_mode (pf ); + +/* Start PTP periodic work after VSI is fully rebuilt */ +ice_ptp_queue_work (pf);return ;
err_vsi_rebuild:drivers/net/ethernet/intel/ice/ice_ptp.c +5
-0@@ -2817,6 +2817,20 @@ static void ice_ptp_periodic_work(struct kthread_work *work) msecs_to_jiffies(err ? 10 : 500)); } +/** +* ice_ptp_queue_work - Queue PTP periodic work for a PF +* @pf: Board private structure +* +* Helper function to queue PTP periodic work after VSI rebuild completes.
+ * This ensures that PTP work only runs when VSI structures are ready.
+ */drivers/net/ethernet/intel/ice/ice_ptp.c +4
-0+void ice_ptp_queue_work (struct ice_pf *pf) { +if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags) && + pf->ptp.state ==ICE_PTP_READY ) + kthread_queue_delayed_work(pf->ptp.kworker, &pf-Quoted 1 line
ptp.work, 0); }
+
/**
*ice_ptp_prepare_rebuild_sec- Prepare second NAC for PTP reset or
rebuild
* @pf: Board private structuredrivers/net/ethernet/intel/ice/ice_ptp.c +0
-0@@ -2835,10 +2849,15 @@ static void ice_ptp_prepare_rebuild_sec(struct ice_pf *pf, bool rebuild, struct ice_pf *peer_pf = ptp_port_to_pf(port);
Quoted 11 lines
Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +3
-1if (!ice_is_primary (&peer_pf->hw)) { -if (rebuild) +if (rebuild) { +/* TODO: When implementing rebuild=true: +* 1. Ensure secondary PFs' VSIs are rebuilt
+ * 2. Callice_ptp_queue_work(peer_pf)
after VSI rebuild
+ */Shouldn't we resolve all TODOs before merging?
now the code only set rebuild = false.
This note is for future if anyone implement secondary PFs rebuilt, So add todo here.
Thanks for review.
Aaron
Quoted 44 lines
Quoted 43 lines
ice_ptp_rebuild(peer_pf, reset_type);drivers/net/ethernet/intel/ice/ice_ptp.c +1
-1-else + }else { ice_ptp_prepare_for_reset(peer_pf,
reset_type);drivers/net/ethernet/intel/ice/ice_ptp.c +1
-3+ } } } }@@ -2984,9 +3003,6 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) ptp->state = ICE_PTP_READY; -/* Start periodic work going */ -kthread_queue_delayed_work (ptp->kworker, &ptp->work,0 ); -dev_info (ice_pf_to_dev (pf),"PTP reset successful\n" );return ;drivers/net/ethernet/intel/ice/ice_ptp.h +0
-0@@ -317,6 +317,7 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf,void
ice_ptp_init(struct ice_pf *pf); voidice_ptp_release(struct ice_pf *pf); voidice_ptp_link_change(struct ice_pf *pf, bool linkup);
+voidice_ptp_queue_work(struct ice_pf *pf);
#else /*IS_ENABLED(CONFIG_PTP_1588_CLOCK)*/static inline int ice_ptp_hwtstamp_get(struct
net_device*netdev, @@
-383,6 +384,10 @@ static inline voidice_ptp_link_change(struct ice_pf *pf, bool linkup){ }drivers/net/ethernet/intel/ice/ice_ptp.h +2
-1+static inline void ice_ptp_queue_work (struct ice_pf *pf) { } +static inline int ice_ptp_clock_index (struct ice_pf *pf) {return -1 ; --2.43.0
Quoted 45 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Aaron Ma via Intel-wired-lan
Sent: Tuesday, January 20, 2026 11:51 PM
To: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]; [email protected]; [email protected]; > [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [Intel-wired-lan] [PATCH] ice: Fix PTP NULL pointer dereference during VSI rebuildFix race condition where PTP periodic work runs while VSI is being rebuilt, accessing NULL
vsi->rx_rings.The sequence was:
1.ice_ptp_prepare_for_reset()cancels PTP work
2.ice_ptp_rebuild()immediately queues PTP work
3. VSI rebuild happens AFTERice_ptp_rebuild()
4. PTP work runs and accesses NULLvsi->rx_ringsFix: Keep PTP work cancelled during rebuild, only queue it after VSI rebuild completes in
ice_rebuild().Added
ice_ptp_queue_work()helper function to encapsulate the logic for queuing PTP work, ensuring it's only queued when PTP is supported and the state isICE_PTP_READY.Error log:
[ 121.392544] ice 0000:60:00.1: PTP reset successful [ 121.392692] BUG: kernel NULL pointer dereference, address: 0000000000000000 [ 121.392712] #PF: supervisor read access in kernel mode [ 121.392720] #PF: error_code(0x0000) - not-present page [ 121.392727] PGD 0 [ 121.392734] Oops: Oops: 0000 [#1] SMP NOPTI [ 121.392746] CPU: 8 UID: 0 PID: 1005 Comm: ice-ptp-0000:60 Tainted: G S 6.19.0-rc6+ #4 PREEMPT(voluntary) [ 121.392761] Tainted: [S]=CPU_OUT_OF_SPEC [ 121.392773] RIP: 0010:ice_ptp_update_cached_phctime+0xbf/0x150 [ice] [ 121.393042] Call Trace: [ 121.393047] <TASK> [ 121.393055] ice_ptp_periodic_work+0x69/0x180 [ice] [ 121.393202] kthread_worker_fn+0xa2/0x260 [ 121.393216] ? __pfx_ice_ptp_periodic_work+0x10/0x10 [ice] [ 121.393359] ? __pfx_kthread_worker_fn+0x10/0x10 [ 121.393371] kthread+0x10d/0x230 [ 121.393382] ? __pfx_kthread+0x10/0x10 [ 121.393393] ret_from_fork+0x273/0x2b0 [ 121.393407] ? __pfx_kthread+0x10/0x10 [ 121.393417] ret_from_fork_asm+0x1a/0x30 [ 121.393432] </TASK>
Quoted 7 lines
Fixes 803bef817807d ("ice: factor out ice_ptp_rebuild_owner()")Signed-off-by Aaron Ma <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 3 +++ drivers/net/ethernet/intel/ice/ice_ptp.c | 26 ++++++++++++++++++----- drivers/net/ethernet/intel/ice/ice_ptp.h | 5 +++++ 3 files changed, 29 insertions(+), 5 deletions(-)