From: sashiko-bot@kernel.org
To: "Linlin Zhang" <linlin.zhang@oss.qualcomm.com>
Cc: conor+dt@kernel.org, robh@kernel.org, linux-scsi@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v1 10/11] blk-crypto: add slot_offset to blk_crypto_profile
Date: Thu, 27 Aug 2026 16:23:39 +0000 [thread overview]
Message-ID: <20260827162339.BA8101F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827160806.1295313-11-linlin.zhang@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] Loops iterating over keyslots in block and driver crypto initialization and reprogramming paths pass logical indices instead of physical indices to keyslot_program/keyslot_evict, failing to account for the new slot_offset.
--
commit 2859a14efba8a99150c0d93c45a6b7ad003d0250
Author: linlzhan <linlin.zhang@oss.qualcomm.com>
blk-crypto: add slot_offset to blk_crypto_profile
On platforms where ICE keyslots are partitioned across the host and
guest VMs, the host's physical keyslot range does not necessarily start
at slot 0. blk_crypto_keyslot_index() currently returns a 0-based
array index, which is wrong for such configurations — hardware
programming requires the physical slot number, not the array position.
Add an unsigned int slot_offset field to struct blk_crypto_profile.
It defaults to zero (no change for existing drivers) and is set by
storage drivers that share ICE hardware across guests.
Update blk_crypto_keyslot_index() to add slot_offset to the array
index so that callers always receive the correct physical ICE keyslot
number to program into hardware.
> diff --git a/block/blk-crypto-profile.c b/block/blk-crypto-profile.c
> index 53126c091b0be..64202d64a0182 100644
> --- a/block/blk-crypto-profile.c
> +++ b/block/blk-crypto-profile.c
> @@ -218,14 +218,15 @@ blk_crypto_find_and_grab_keyslot(struct blk_crypto_profile *profile,
> }
>
> /**
> - * blk_crypto_keyslot_index() - Get the index of a keyslot
> + * blk_crypto_keyslot_index() - Get the physical index of a keyslot
> * @slot: a keyslot that blk_crypto_get_keyslot() returned
> *
> - * Return: the 0-based index of the keyslot within the device's keyslots.
> + * Return: the physical ICE keyslot index, i.e. the 0-based position of @slot
> + * within the profile's keyslot array plus @slot->profile->slot_offset.
> */
> unsigned int blk_crypto_keyslot_index(struct blk_crypto_keyslot *slot)
> {
> - return slot - slot->profile->slots;
> + return (slot - slot->profile->slots) + slot->profile->slot_offset;
> }
> EXPORT_SYMBOL_GPL(blk_crypto_keyslot_index);
>
[ ... ]
> diff --git a/include/linux/blk-crypto-profile.h b/include/linux/blk-crypto-profile.h
> index 4f39e9cd75766..a9bdc05abfa3c 100644
> --- a/include/linux/blk-crypto-profile.h
> +++ b/include/linux/blk-crypto-profile.h
> @@ -162,6 +162,15 @@ struct blk_crypto_profile {
> */
> struct device *dev;
>
> + /**
> + * @slot_offset: offset added to the slot array index to obtain the
> + * physical ICE keyslot number. Zero in the common case. Set to a
> + * non-zero value by storage drivers that share ICE hardware across
> + * multiple guests, where the host's keyslots do not start at physical
> + * slot 0.
> + */
> + unsigned int slot_offset;
> +
[Severity: Critical]
Does this new slot_offset need to be applied in loops that manually iterate
over keyslots?
For example, in block/blk-crypto-profile.c:blk_crypto_reprogram_all_keys(),
the logical loop counter slot is passed directly to keyslot_program():
for (slot = 0; slot < profile->num_slots; slot++) {
...
err = profile->ll_ops.keyslot_program(profile, key, slot);
...
}
Since this bypasses the new slot_offset, will it program keys into physical
slots starting at 0 during device resume, corrupting foreign keyslots belonging
to the host or other VMs?
Similarly, in drivers/ufs/core/ufshcd-crypto.c:ufshcd_init_crypto():
for (slot = 0; slot < hba->crypto_profile.num_slots; slot++)
hba->crypto_profile.ll_ops.keyslot_evict(&hba->crypto_profile,
NULL, slot);
And in drivers/mmc/host/cqhci-crypto.c:cqhci_crypto_init():
for (slot = 0; slot < profile->num_slots; slot++)
profile->ll_ops.keyslot_evict(profile, NULL, slot);
Do these initialization paths also incorrectly evict physical keyslots starting
at 0 because they ignore slot_offset, destroying host/guest ICE keyslots?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827160806.1295313-1-linlin.zhang@oss.qualcomm.com?part=10
next prev parent reply other threads:[~2026-08-27 16:23 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 16:07 [PATCH v1 00/11] FBE virtualization: inline encryption for virtio-blk guests Linlin Zhang
2026-08-27 16:07 ` [PATCH v1 01/11] virtio_blk: add inline encryption support Linlin Zhang
2026-08-27 16:23 ` sashiko-bot
2026-09-01 19:48 ` Stefan Hajnoczi
2026-09-02 5:58 ` Linlin Zhang
2026-08-27 16:07 ` [PATCH v1 02/11] soc: qcom: add crypto_virt backend for virtio-blk inline crypto Linlin Zhang
2026-08-27 16:24 ` sashiko-bot
2026-08-31 6:56 ` Krzysztof Kozlowski
2026-09-01 9:39 ` Linlin Zhang
2026-09-01 13:58 ` Krzysztof Kozlowski
2026-09-02 15:01 ` Linlin Zhang
2026-09-03 8:16 ` Krzysztof Kozlowski
2026-08-27 16:07 ` [PATCH v1 03/11] soc: qcom: crypto_virt: add support for create, prepare and import keys Linlin Zhang
2026-08-27 16:19 ` sashiko-bot
2026-08-31 6:58 ` Krzysztof Kozlowski
2026-09-01 10:31 ` Linlin Zhang
2026-09-01 14:01 ` Krzysztof Kozlowski
2026-09-02 15:33 ` Linlin Zhang
2026-08-27 16:07 ` [PATCH v1 04/11] dt-bindings: soc: qcom: add binding for qcom,crypto-virt Linlin Zhang
2026-08-27 16:14 ` sashiko-bot
2026-08-31 7:01 ` Krzysztof Kozlowski
2026-09-01 10:40 ` Linlin Zhang
2026-08-27 16:07 ` [PATCH v1 05/11] blk-crypto: add slot-based inline encryption path Linlin Zhang
2026-08-27 16:26 ` sashiko-bot
2026-09-01 19:06 ` Stefan Hajnoczi
2026-08-27 16:07 ` [PATCH v1 06/11] scsi: ufs: core: add slot path to ufshcd_prepare_lrbp_crypto Linlin Zhang
2026-08-27 16:20 ` sashiko-bot
2026-09-01 19:08 ` Stefan Hajnoczi
2026-08-27 16:07 ` [PATCH v1 07/11] blk-crypto: move bio_crypt_dun_increment() to the public header Linlin Zhang
2026-08-27 16:18 ` sashiko-bot
2026-09-01 19:13 ` Stefan Hajnoczi
2026-09-02 6:02 ` Linlin Zhang
2026-08-27 16:07 ` [PATCH v1 08/11] block: add /dev/blk-crypto-proxy for host-side virtio-blk inline encryption Linlin Zhang
2026-08-27 16:24 ` sashiko-bot
2026-09-01 19:43 ` Stefan Hajnoczi
2026-09-02 13:14 ` Linlin Zhang
2026-08-27 16:07 ` [PATCH v1 09/11] soc: qcom: add ICE keyslot partitioning driver for guest VMs Linlin Zhang
2026-08-27 16:17 ` sashiko-bot
2026-08-31 7:02 ` Krzysztof Kozlowski
2026-09-01 10:48 ` Linlin Zhang
2026-08-27 16:07 ` [PATCH v1 10/11] blk-crypto: add slot_offset to blk_crypto_profile Linlin Zhang
2026-08-27 16:23 ` sashiko-bot [this message]
2026-08-27 16:07 ` [PATCH v1 11/11] scsi: ufs: ufs-qcom: support ICE keyslot partitioning for guest VMs Linlin Zhang
2026-08-27 16:26 ` sashiko-bot
2026-08-31 7:03 ` Krzysztof Kozlowski
2026-09-01 10:54 ` Linlin Zhang
2026-09-01 14:02 ` Krzysztof Kozlowski
2026-09-02 15:03 ` Linlin Zhang
2026-08-27 18:42 ` [PATCH v1 00/11] FBE virtualization: inline encryption for virtio-blk guests Eric Biggers
2026-08-28 15:37 ` Linlin Zhang
2026-08-28 15:56 ` Linlin Zhang
2026-08-31 6:21 ` Linlin Zhang
2026-08-31 20:41 ` Stefan Hajnoczi
2026-09-01 9:21 ` Linlin Zhang
2026-09-01 18:47 ` Stefan Hajnoczi
2026-08-31 21:07 ` Eric Biggers
2026-09-01 8:22 ` Linlin Zhang
2026-09-01 8:45 ` Linlin Zhang
2026-09-01 19:44 ` Stefan Hajnoczi
2026-09-02 8:15 ` Linlin Zhang
2026-09-01 21:28 ` Eric Biggers
2026-09-02 14:33 ` Linlin Zhang
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=20260827162339.BA8101F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linlin.zhang@oss.qualcomm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.