• Andy Grover's avatar
    target/iscsi: Fix network portal creation race · 85c3c54b
    Andy Grover authored
    commit ee291e63293146db64668e8d65eb35c97e8324f4 upstream.
    
    When creating network portals rapidly, such as when restoring a
    configuration, LIO's code to reuse existing portals can return a false
    negative if the thread hasn't run yet and set np_thread_state to
    ISCSI_NP_THREAD_ACTIVE. This causes an error in the network stack
    when attempting to bind to the same address/port.
    
    This patch sets NP_THREAD_ACTIVE before the np is placed on g_np_list,
    so even if the thread hasn't run yet, iscsit_get_np will return the
    existing np.
    
    Also, convert np_lock -> np_mutex + hold across adding new net portal
    to g_np_list to prevent a race where two threads may attempt to create
    the same network portal, resulting in one of them failing.
    
    (nab: Add missing mutex_unlocks in iscsit_add_np failure paths)
    (DanC: Fix incorrect spin_unlock -> spin_unlock_bh)
    Signed-off-by: 's avatarAndy Grover <agrover@redhat.com>
    Signed-off-by: 's avatarNicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    85c3c54b
Name
Last commit
Last update
..
iscsi Loading commit data...
loopback Loading commit data...
sbp Loading commit data...
tcm_fc Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
target_core_alua.c Loading commit data...
target_core_alua.h Loading commit data...
target_core_configfs.c Loading commit data...
target_core_device.c Loading commit data...
target_core_fabric_configfs.c Loading commit data...
target_core_fabric_lib.c Loading commit data...
target_core_file.c Loading commit data...
target_core_file.h Loading commit data...
target_core_hba.c Loading commit data...
target_core_iblock.c Loading commit data...
target_core_iblock.h Loading commit data...
target_core_internal.h Loading commit data...
target_core_pr.c Loading commit data...
target_core_pr.h Loading commit data...
target_core_pscsi.c Loading commit data...
target_core_pscsi.h Loading commit data...
target_core_rd.c Loading commit data...
target_core_rd.h Loading commit data...
target_core_sbc.c Loading commit data...
target_core_spc.c Loading commit data...
target_core_stat.c Loading commit data...
target_core_tmr.c Loading commit data...
target_core_tpg.c Loading commit data...
target_core_transport.c Loading commit data...
target_core_ua.c Loading commit data...
target_core_ua.h Loading commit data...