Skip to content

Commit

Permalink
scsi: fix random memory corruption with scsi-mq + T10 PI
Browse files Browse the repository at this point in the history
This fixes random memory corruption triggered when all three of the
following are true:

* scsi-mq enabled
* T10 Protection Information (DIF) enabled
* SCSI host with sg_tablesize > SCSI_MAX_SG_SEGMENTS (128)

The symptoms of this bug are unpredictable memory corruption, BUG()s,
oopses, lockups, etc., any of which may appear to be completely
unrelated to the root cause.

Cc: <stable@vger.kernel.org> # 3.17.x, 3.18.x
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Tony Battersby authored and Christoph Hellwig committed Dec 15, 2014
1 parent 67e2c38 commit 120bb3e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,9 @@ static int scsi_mq_prep_fn(struct request *req)

if (scsi_host_get_prot(shost)) {
cmd->prot_sdb = (void *)sg +
shost->sg_tablesize * sizeof(struct scatterlist);
min_t(unsigned int,
shost->sg_tablesize, SCSI_MAX_SG_SEGMENTS) *
sizeof(struct scatterlist);
memset(cmd->prot_sdb, 0, sizeof(struct scsi_data_buffer));

cmd->prot_sdb->table.sgl =
Expand Down

0 comments on commit 120bb3e

Please sign in to comment.