From 609325d29bf6b01b7c4cd1c7c5069bc62571bd84 Mon Sep 17 00:00:00 2001 From: Folkert van Heusden Date: Wed, 9 Oct 2024 20:31:00 +0200 Subject: [PATCH] WRITE_SAME with WRPROTECT set is not supported --- scsi.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scsi.cpp b/scsi.cpp index 3a9c86f..0e41003 100644 --- a/scsi.cpp +++ b/scsi.cpp @@ -851,6 +851,11 @@ std::optional > scsi::validate_request(const uint64_t lba, DOLOG(logging::ll_debug, "scsi::validate_request", "-", "WRITE_SAME with ANCHOR=1 and UNMAP=0 is a failure"); return error_invalid_field(); } + + if ((opcode == o_write_10 || opcode == o_write_16 || opcode == o_write_verify_10 || opcode == o_write_same_10 || opcode == o_write_same_16) && (CDB[1] >> 5) != 0) { + DOLOG(logging::ll_debug, "scsi::validate_request", "-", "WRITE_SAME with WRPROTECT set is not supported"); + return error_invalid_field(); + } } return { }; // no error