Re: [PATCH 1/1] scsi: ufs: core: Fix error handler encryption support
From: Christoph Hellwig
Date: Wed Dec 10 2025 - 01:48:32 EST
On Mon, Dec 08, 2025 at 02:52:21AM +0000, Po-Wen Kao wrote:
> From: Brian Kao <powenkao@xxxxxxxxxx>
>
> The UFS driver utilizes block layer crypto fields, such as
> rq->crypt_keyslot and rq->crypt_ctx, to configure hardware for inline
> encryption. However, the SCSI error handler (EH) reuses the
> Protocol Data Unit (PDU) from the original failing request when issuing
> EH commands (e.g., TEST UNIT READY, START STOP UNIT).
>
> This can lead to issues if the original request of reused PDU contains
> stale cryptographic configurations, which are not applicable for
> the simple EH commands. These commands should not involve data
> encryption.
>
> This patch fixes this by checking if the command was submitted by the
> SCSI error handler. If so, it bypasses the cryptographic setup for
> the request, ensuring UTRDs are not inadvertently
> configured with potentially incorrect encryption parameters.
As mentioned last round, why are you even calling into the crypto
code here? Calling that for a request without a crypt context,
which includes all of them that do not transfer any data makes no
sense to start with.