Skip to content

Commit dd6e972

Browse files
dtatuleakuba-moo
authored andcommitted
net/mlx5e: kTLS, Fix incorrect page refcounting
The kTLS tx handling code is using a mix of get_page() and page_ref_inc() APIs to increment the page reference. But on the release path (mlx5e_ktls_tx_handle_resync_dump_comp()), only put_page() is used. This is an issue when using pages from large folios: the get_page() references are stored on the folio page while the page_ref_inc() references are stored directly in the given page. On release the folio page will be dereferenced too many times. This was found while doing kTLS testing with sendfile() + ZC when the served file was read from NFS on a kernel with NFS large folios support (commit 49b29a5 ("nfs: add support for large folios")). Fixes: 84d1bb2 ("net/mlx5e: kTLS, Limit DUMP wqe size") Signed-off-by: Dragos Tatulea <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9ca3144 commit dd6e972

File tree

1 file changed

+4
-4
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+4
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ tx_sync_info_get(struct mlx5e_ktls_offload_context_tx *priv_tx,
660660
while (remaining > 0) {
661661
skb_frag_t *frag = &record->frags[i];
662662

663-
get_page(skb_frag_page(frag));
663+
page_ref_inc(skb_frag_page(frag));
664664
remaining -= skb_frag_size(frag);
665665
info->frags[i++] = *frag;
666666
}
@@ -763,7 +763,7 @@ void mlx5e_ktls_tx_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
763763
stats = sq->stats;
764764

765765
mlx5e_tx_dma_unmap(sq->pdev, dma);
766-
put_page(wi->resync_dump_frag_page);
766+
page_ref_dec(wi->resync_dump_frag_page);
767767
stats->tls_dump_packets++;
768768
stats->tls_dump_bytes += wi->num_bytes;
769769
}
@@ -816,12 +816,12 @@ mlx5e_ktls_tx_handle_ooo(struct mlx5e_ktls_offload_context_tx *priv_tx,
816816

817817
err_out:
818818
for (; i < info.nr_frags; i++)
819-
/* The put_page() here undoes the page ref obtained in tx_sync_info_get().
819+
/* The page_ref_dec() here undoes the page ref obtained in tx_sync_info_get().
820820
* Page refs obtained for the DUMP WQEs above (by page_ref_add) will be
821821
* released only upon their completions (or in mlx5e_free_txqsq_descs,
822822
* if channel closes).
823823
*/
824-
put_page(skb_frag_page(&info.frags[i]));
824+
page_ref_dec(skb_frag_page(&info.frags[i]));
825825

826826
return MLX5E_KTLS_SYNC_FAIL;
827827
}

0 commit comments

Comments
 (0)