List, Tomo Please find a small patch attached that expands the 'check we are not reading beyond end-of-lun' to also cover the write case and make WRITE* CDBs also fail with the correct sense key/ascq regards ronnie sahlberg
Attachment:
0001-Verify-that-we-are-not-writing-beyond-the-end-of-the.patch.gz
Description: GNU Zip compressed data
From 8d0b0558227de16f8861a226a2df93ff3bd35b4c Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> Date: Sat, 16 Apr 2011 07:37:36 +1000 Subject: [PATCH] Verify that we are not writing beyond the end of the lun Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> --- usr/sbc.c | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-) diff --git a/usr/sbc.c b/usr/sbc.c index f7b1e17..a5fb754 100644 --- a/usr/sbc.c +++ b/usr/sbc.c @@ -128,19 +128,12 @@ static int sbc_rw(int host_no, struct scsi_cmd *cmd) lba = scsi_rw_offset(cmd->scb) << cmd->dev->blk_shift; tl = scsi_rw_count(cmd->scb) << cmd->dev->blk_shift; - /* Verify that if we are reading data that we are not reading beyond + /* Verify that we are not doing i/o beyond the end-of-lun */ - switch (cmd->scb[0]) { - case READ_6: - case READ_10: - case READ_12: - case READ_16: - if (tl && (lba + tl > lu->size)) { - key = ILLEGAL_REQUEST; - asc = ASC_LBA_OUT_OF_RANGE; - goto sense; - } - break; + if (tl && (lba + tl > lu->size)) { + key = ILLEGAL_REQUEST; + asc = ASC_LBA_OUT_OF_RANGE; + goto sense; } cmd->scsi_cmd_done = target_cmd_io_done; -- 1.7.3.1