-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
3
-
9223372036854775807
An allocation failure in kiblnd_create_tx_pool() makes kiblnd_destroy_tx_pool() dereference a NULL pointer.
Mechanism
kiblnd_create_tx_pool() zeroes all tpo_tx_descs with memset(). It then allocates the per-tx arrays in a loop. On an allocation failure, the loop stops with break, and the function calls ps->ps_pool_destroy().
kiblnd_destroy_tx_pool() calls list_del(&tx->tx_list) for each of the po_size descriptors. Only kiblnd_map_tx_pool() adds a descriptor to po_free_list, and the create function calls it only after the loop completes. On the failure path, every tx_list is still zero. list_del() then writes through a NULL next pointer.
kiblnd_create_tx_pool() memset(tpo->tpo_tx_descs, 0, ...) for (i = 0; i < size; i++) LIBCFS_CPT_ALLOC(...) fails -> break ps->ps_pool_destroy(pool) kiblnd_destroy_tx_pool() list_del(&tx->tx_list) <- tx_list.next == NULL
Trigger
Any of the per-tx allocations (tx_pages, tx_frags, tx_wrq, tx_sge, tx_rd) fails under memory pressure. The failure can happen at LNet startup or when the pool set grows.
Fix
Initialize tx_list of each descriptor before the allocation loop, so that list_del() is safe on the failure path.
The defect is source-only. Nobody has seen the crash in a log. A code review found the defect on current master.