summaryrefslogtreecommitdiff
path: root/include/scsi
diff options
context:
space:
mode:
authorBrian Kao <powenkao@google.com>2025-12-18 03:17:23 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-01-30 10:27:26 +0100
commit8fab42516eb3cc37c0514f66e8ad91581bdef7a4 (patch)
treebac96cd99c9d45547974758760aecfd9f9af9eb2 /include/scsi
parent60e450eec5d63113c6ad5c456ce64c12b4496a6e (diff)
downloadlinux-8fab42516eb3cc37c0514f66e8ad91581bdef7a4.tar.gz
linux-8fab42516eb3cc37c0514f66e8ad91581bdef7a4.tar.bz2
linux-8fab42516eb3cc37c0514f66e8ad91581bdef7a4.zip
scsi: core: Fix error handler encryption support
commit 9a49157deeb23581fc5c8189b486340d7343264a upstream. Some low-level drivers (LLD) access block layer crypto fields, such as rq->crypt_keyslot and rq->crypt_ctx within `struct request`, to configure hardware for inline encryption. However, SCSI Error Handling (EH) commands (e.g., TEST UNIT READY, START STOP UNIT) should not involve any encryption setup. To prevent drivers from erroneously applying crypto settings during EH, this patch saves the original values of rq->crypt_keyslot and rq->crypt_ctx before an EH command is prepared via scsi_eh_prep_cmnd(). These fields in the 'struct request' are then set to NULL. The original values are restored in scsi_eh_restore_cmnd() after the EH command completes. This ensures that the block layer crypto context does not leak into EH command execution. Signed-off-by: Brian Kao <powenkao@google.com> Link: https://patch.msgid.link/20251218031726.2642834-1-powenkao@google.com Cc: stable@vger.kernel.org Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/scsi_eh.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 1ae08e81339f..15679be90c5c 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -41,6 +41,12 @@ struct scsi_eh_save {
unsigned char cmnd[32];
struct scsi_data_buffer sdb;
struct scatterlist sense_sgl;
+
+ /* struct request fields */
+#ifdef CONFIG_BLK_INLINE_ENCRYPTION
+ struct bio_crypt_ctx *rq_crypt_ctx;
+ struct blk_crypto_keyslot *rq_crypt_keyslot;
+#endif
};
extern void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd,