Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: RDMA/srp: Don't set a max_segment_size when virt_boundary_mask is set

virt_boundary_mask implies an unlimited max_segment_size. Setting both
can lead to data corruption because __blk_rq_map_sg() can split requests
so that the virt_boundary_mask is not respected if max_segment_size is
not UINT_MAX.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250624125233.219635-2-hch@lst.de
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Acked-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Christoph Hellwig and committed by
Martin K. Petersen
844c6a16 8889676c

+3 -2
+3 -2
drivers/infiniband/ulp/srp/ib_srp.c
··· 3705 3705 target_host->max_id = 1; 3706 3706 target_host->max_lun = -1LL; 3707 3707 target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb; 3708 - target_host->max_segment_size = ib_dma_max_seg_size(ibdev); 3709 3708 3710 - if (!(ibdev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG)) 3709 + if (ibdev->attrs.kernel_cap_flags & IBK_SG_GAPS_REG) 3710 + target_host->max_segment_size = ib_dma_max_seg_size(ibdev); 3711 + else 3711 3712 target_host->virt_boundary_mask = ~srp_dev->mr_page_mask; 3712 3713 3713 3714 target = host_to_target(target_host);