Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Po-Wen Kao <powenkao@google.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER"
	<linux-scsi@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	Eric Biggers <ebiggers@kernel.org>
Subject: Re: [PATCH 1/1] scsi: ufs: core: Fix error handler encryption support
Date: Tue, 9 Dec 2025 09:53:51 -0800	[thread overview]
Message-ID: <a00f5bc6-02a0-41cb-8da6-1df779831430@acm.org> (raw)
In-Reply-To: <20251208025232.4068621-1-powenkao@google.com>

On 12/7/25 6:52 PM, Po-Wen Kao wrote:
> From: Brian Kao <powenkao@google.com>
> 
> 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.
> 
> Signed-off-by: Brian Kao <powenkao@google.com>
> ---
>   drivers/ufs/core/ufshcd-crypto.h | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufshcd-crypto.h b/drivers/ufs/core/ufshcd-crypto.h
> index c148a5194378..26a0699c8412 100644
> --- a/drivers/ufs/core/ufshcd-crypto.h
> +++ b/drivers/ufs/core/ufshcd-crypto.h
> @@ -16,7 +16,12 @@
>   static inline void ufshcd_prepare_lrbp_crypto(struct request *rq,
>   					      struct ufshcd_lrb *lrbp)
>   {
> -	if (!rq || !rq->crypt_keyslot) {
> +	/*
> +	 * Do not use the crypto settings if the SCSI error handler has replaced
> +	 * the SCSI command
> +	 */
> +	if (!rq || !rq->crypt_keyslot ||
> +	    unlikely(lrbp->cmd->submitter == SUBMITTED_BY_SCSI_ERROR_HANDLER)) {
>   		lrbp->crypto_key_slot = -1;
>   		return;
>   	}

(+Christoph Hellwig and Eric Biggers)

Cc: stable@vger.kernel.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>

  reply	other threads:[~2025-12-09 17:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08  2:52 [PATCH 1/1] scsi: ufs: core: Fix error handler encryption support Po-Wen Kao
2025-12-09 17:53 ` Bart Van Assche [this message]
2025-12-10  6:48 ` Christoph Hellwig
2025-12-10 17:44   ` Bart Van Assche
2025-12-15  5:58     ` Christoph Hellwig
2025-12-15 16:47       ` Bart Van Assche
2025-12-16 10:44         ` Christoph Hellwig
2025-12-16 17:57           ` Bart Van Assche

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a00f5bc6-02a0-41cb-8da6-1df779831430@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=ebiggers@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=powenkao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox