• Vasu Dev's avatar
    [SCSI] libfc: possible race could panic system due to NULL fsp->cmd · 8b7ac2bb
    Vasu Dev authored
    It is unlikely but in case if it hits then it would cause panic
    due to null cmd ptr, so far only one instance seen recently with
    ESX though this was introduced long ago with this commit:-
    
    commit c1ecb90a
    Author: Chris Leech <christopher.leech@intel.com>
    Date:   Thu Dec 10 09:59:26 2009 -0800
    [SCSI] libfc: reduce hold time on SCSI host lock
    
    Currently fsp->cmd is set to NULL w/o scsi_queue_lock before
    dequeuing from scsi_pkt_queue and that could cause NULL
    fsp->cmd in fc_fcp_cleanup_each_cmd for cmd completing
    with fsp->cmd = NULL after fc_fcp_cleanup_each_cmd taken
    reference. No need to set fsp->cmd to NULL as this is also
    protected by fc_fcp_lock_pkt(), for above race the
    fc_fcp_lock_pkt() in fc_fcp_cleanup_each_cmd() will fail
    as that cmd is  already done.
    
    Mike mentioned same issue at
    http://www.open-fcoe.org/pipermail/devel/2010-September/010533.html
    
    Similarly moved sc_cmd->SCp.ptr = NULL under scsi_queue_lock so
    that scsi abort error handler won't abort on completed cmds.
    Signed-off-by: default avatarVasu Dev <vasu.dev@intel.com>
    Signed-off-by: default avatarRobert Love <robert.w.love@intel.com>
    Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
    8b7ac2bb
fc_fcp.c 58.2 KB