From: sashiko-bot@kernel.org
To: "Linlin Zhang" <linlin.zhang@oss.qualcomm.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH v1 09/11] soc: qcom: add ICE keyslot partitioning driver for guest VMs
Date: Thu, 27 Aug 2026 16:17:18 +0000 [thread overview]
Message-ID: <20260827161719.164651F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827160806.1295313-10-linlin.zhang@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Probe error path leaves a dangling pointer in the global `g_ice_slots`, leading to a Use-After-Free.
- [Medium] Implicit assumptions about Device Tree node ordering falsely reject valid, disjoint keyslot allocations.
--
commit 298e1c705033929570b5634f841cfc46474229cd
Author: linlzhan <linlin.zhang@oss.qualcomm.com>
soc: qcom: add ICE keyslot partitioning driver for guest VMs
On Qualcomm platforms the ICE hardware has a fixed number of physical
keyslots shared across the host and all guest VMs. Add the QCOM_ICE_SLOTS
platform driver to parse qcom,ice-keyslot-map DT nodes and map guest
virtual keyslot indices to physical keyslots allocated to each VM.
> diff --git a/drivers/soc/qcom/qcom_ice_slots.c b/drivers/soc/qcom/qcom_ice_slots.c
> new file mode 100644
> index 0000000000000..364ac93077c12
> --- /dev/null
> +++ b/drivers/soc/qcom/qcom_ice_slots.c
[ ... ]
> +static int qcom_ice_slots_get_guest_slots(struct blk_crypto_profile *profile,
> + u32 guest_id)
> +{
> + struct qcom_ice_slots *virt = virt_lookup(profile);
> + unsigned int i;
> +
> + if (!virt)
> + return -ENOKEY;
> +
> + /* entries[0] is the host; guest entries start at index 1. */
> + for (i = 1; i < virt->num_entries; i++) {
[Severity: Medium]
Does this loop skip index 0 by hardcoding the assumption that the very first
parsed DT child node corresponds to the host?
This hides the first parsed entry from guest translation regardless of its
actual properties, which breaks guest VM keyslot partitioning if the host is
not the first child node in the device tree.
> + if (virt->entries[i].guest_id == guest_id)
> + return virt->entries[i].max_slots;
> + }
> + return -ENOKEY;
> +}
[ ... ]
> +static int qcom_ice_slots_probe(struct platform_device *pdev)
> +{
[ ... ]
> + if (idx > 0 &&
> + slot_offset <
> + virt->entries[idx - 1].slot_offset +
> + virt->entries[idx - 1].max_slots) {
[Severity: Medium]
Can this logic falsely abort the probe when the nodes are disjoint but appear
out-of-order in the Device Tree?
This check only verifies the current entry's offset against the immediate
predecessor's end. If the nodes are legitimately sorted by their unit-address
reg instead of slot_offset, this mathematically flawed check evaluates to true
and falsely rejects valid physical keyslot mappings.
> + dev_err(dev, "slot overlap: guest_id=%u overlaps guest_id=%u\n",
> + guest_id, virt->entries[idx - 1].guest_id);
> + ret = -EINVAL;
> + of_node_put(child);
> + goto err_free;
> + }
[ ... ]
> + virt->num_entries = idx;
> +
> + /*
> + * Publish the singleton. From this point on, bcp_slot_virt_ops
> + * callbacks can resolve virt via rcu_dereference(g_ice_slots).
> + */
> + rcu_assign_pointer(g_ice_slots, virt);
> +
> + ret = bcp_register_slot_virt_ops(&qcom_slot_virt_ops);
> + if (ret) {
> + dev_err(dev, "failed to register slot_virt_ops: %d\n", ret);
> + goto err_free;
> + }
[Severity: High]
Is it possible for this error path to leave a dangling pointer in the global
g_ice_slots resulting in a use-after-free regression?
The devm-allocated virt state is published to the global g_ice_slots pointer
via rcu_assign_pointer(). If bcp_register_slot_virt_ops() fails, the function
returns via the err_free label without setting g_ice_slots back to NULL.
When the devres framework subsequently frees virt, it leaves a dangling pointer
that can be dereferenced by the hot path if blk-crypto-proxy invokes the
still-registered operations.
> +
> + dev_info(dev, "registered: %u VMs, %u total ICE slots\n",
> + idx, total_slots);
> + return 0;
> +
> +err_free:
> + return ret;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827160806.1295313-1-linlin.zhang@oss.qualcomm.com?part=9
next prev parent reply other threads:[~2026-08-27 16:17 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 [this message]
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
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=20260827161719.164651F000E9@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.