Skip to content

Commit 6bb1819

Browse files
committed
ice: fix NULL access of tx->in_use in ice_ptp_ts_irq
jira KERNEL-216 Rebuild_History Non-Buildable kernel-5.14.0-611.9.1.el9_7 commit-author Jacob Keller <jacob.e.keller@intel.com> commit 403bf04 The E810 device has support for a "low latency" firmware interface to access and read the Tx timestamps. This interface does not use the standard Tx timestamp logic, due to the latency overhead of proxying sideband command requests over the firmware AdminQ. The logic still makes use of the Tx timestamp tracking structure, ice_ptp_tx, as it uses the same "ready" bitmap to track which Tx timestamps complete. Unfortunately, the ice_ptp_ts_irq() function does not check if the tracker is initialized before its first access. This results in NULL dereference or use-after-free bugs similar to the following: [245977.278756] BUG: kernel NULL pointer dereference, address: 0000000000000000 [245977.278774] RIP: 0010:_find_first_bit+0x19/0x40 [245977.278796] Call Trace: [245977.278809] ? ice_misc_intr+0x364/0x380 [ice] This can occur if a Tx timestamp interrupt races with the driver reset logic. Fix this by only checking the in_use bitmap (and other fields) if the tracker is marked as initialized. The reset flow will clear the init field under lock before it tears the tracker down, thus preventing any use-after-free or NULL access. Fixes: f9472aa ("ice: Process TSYN IRQ in a separate function") Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> (cherry picked from commit 403bf04) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 9eb0fd9 commit 6bb1819

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,16 +2882,19 @@ irqreturn_t ice_ptp_ts_irq(struct ice_pf *pf)
28822882
*/
28832883
if (hw->dev_caps.ts_dev_info.ts_ll_int_read) {
28842884
struct ice_ptp_tx *tx = &pf->ptp.port.tx;
2885-
u8 idx;
2885+
u8 idx, last;
28862886

28872887
if (!ice_pf_state_is_nominal(pf))
28882888
return IRQ_HANDLED;
28892889

28902890
spin_lock(&tx->lock);
2891-
idx = find_next_bit_wrap(tx->in_use, tx->len,
2892-
tx->last_ll_ts_idx_read + 1);
2893-
if (idx != tx->len)
2894-
ice_ptp_req_tx_single_tstamp(tx, idx);
2891+
if (tx->init) {
2892+
last = tx->last_ll_ts_idx_read + 1;
2893+
idx = find_next_bit_wrap(tx->in_use, tx->len,
2894+
last);
2895+
if (idx != tx->len)
2896+
ice_ptp_req_tx_single_tstamp(tx, idx);
2897+
}
28952898
spin_unlock(&tx->lock);
28962899

28972900
return IRQ_HANDLED;

0 commit comments

Comments
 (0)