Skip to content
  • Akinobu Mita's avatar
    target: ensure se_cmd->t_prot_sg is allocated when required · 5835812f
    Akinobu Mita authored
    
    
    Even if the device backend is initialized with protection info is
    enabled, some requests don't have the protection info attached for
    WRITE SAME command issued by block device helpers, WRITE command with
    WRPROTECT=0 by SG_IO ioctl, etc.
    
    So when TCM loopback fabric module is used, se_cmd->t_prot_sg is NULL
    for these requests and performing WRITE_INSERT of PI using software
    emulation by sbc_dif_generate() causes kernel crash.
    
    To fix this, introduce SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC for
    se_cmd_flags, which is used to determine that se_cmd->t_prot_sg needs
    to be allocated or use pre-allocated protection information by scsi
    mid-layer.
    
    Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
    Cc: Nicholas Bellinger <nab@linux-iscsi.org>
    Cc: Sagi Grimberg <sagig@mellanox.com>
    Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
    Cc: target-devel@vger.kernel.org
    Cc: linux-scsi@vger.kernel.org
    Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
    5835812f