From: sashiko-bot@kernel.org
To: "Li Qiang" <liqiang01@kylinos.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 5/6] scsi: ufs: rpmb: Use unaligned accessors for RPMB frames
Date: Fri, 17 Jul 2026 16:54:59 +0000 [thread overview]
Message-ID: <20260717165459.8F2091F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260717153914.26321-6-liqiang01@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but while the patch correctly fixes unaligned memory accesses in the UFS RPMB backend, identical unsafe accesses remain unpatched in the MMC RPMB backend. Additionally, a structural fix using `__packed` on `struct rpmb_frame` is missing, which would safely handle unaligned access for all backends globally.
--
--- Patch [5]: [PATCH v2 5/6] scsi: ufs: rpmb: Use unaligned accessors for RPMB frames ---
commit 521f1f28960728ee9f0014bd2898bd36bb94fa39
Author: Li Qiang <liqiang01@kylinos.cn>
scsi: ufs: rpmb: Use unaligned accessors for RPMB frames
RPMB frame buffers are passed as u8 pointers and do not have an
alignment guarantee. This commit uses unaligned accessors for the req_resp
field to prevent alignment fault traps.
> diff --git a/drivers/ufs/core/ufs-rpmb.c b/drivers/ufs/core/ufs-rpmb.c
> index 431f85b368760..53f66b274acac 100644
> --- a/drivers/ufs/core/ufs-rpmb.c
> +++ b/drivers/ufs/core/ufs-rpmb.c
> @@ -73,7 +73,7 @@ static int ufs_rpmb_route_frames(struct device *dev, u8 *req, unsigned int req_l
> if (req_len < sizeof(*frm_out))
> return -EINVAL;
>
> - req_type = be16_to_cpu(frm_out->req_resp);
> + req_type = get_unaligned_be16(&frm_out->req_resp);
[Severity: High]
This is a pre-existing issue, but while this correctly fixes the unaligned
memory access in the UFS RPMB backend, does it make sense to fix this globally
by adding the __packed attribute to struct rpmb_frame in include/linux/rpmb.h?
Currently, identical unsafe accesses remain unpatched in the MMC RPMB backend,
such as in mmc_route_rpmb_frames() in drivers/mmc/core/block.c:
drivers/mmc/core/block.c:mmc_route_rpmb_frames() {
...
req_type = be16_to_cpu(frm->req_resp);
...
resp_frm->req_resp = cpu_to_be16(RPMB_RESULT_READ);
...
}
An RPC call from the TEE secure world (e.g., OP-TEE) passing an unaligned
shm_offs to the kernel for an RPMB routing request
(handle_rpc_func_rpmb_frames) can cause tee_shm_get_va() to return an
unaligned u8 * pointer.
The MMC driver casts this to struct rpmb_frame * and dereferences req_resp,
which can trigger an alignment fault trap and kernel panic on architectures
that do not support unaligned memory access.
Would adding __packed to struct rpmb_frame instruct the compiler to safely
generate unaligned accesses for all members globally, avoiding brittle
driver-by-driver accessor fixes?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260717153914.26321-1-liqiang01@kylinos.cn?part=5
next prev parent reply other threads:[~2026-07-17 16:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 6:19 [PATCH 0/5] scsi: ufs: Fix descriptor parsing and invalid input handling liqiang
2026-07-16 6:19 ` [PATCH 1/5] scsi: ufs: core: Validate string descriptors liqiang
2026-07-16 17:47 ` Bart Van Assche
2026-07-17 15:35 ` Li Qiang
2026-07-16 6:19 ` [PATCH 2/5] scsi: ufs: Fix NULL dereferences after tag lookup liqiang
2026-07-16 6:43 ` sashiko-bot
2026-07-16 17:52 ` Bart Van Assche
2026-07-16 6:19 ` [PATCH 3/5] scsi: ufs: core: Validate connected lane counts liqiang
2026-07-16 6:19 ` [PATCH 4/5] scsi: ufs: rpmb: Validate frame before parsing liqiang
2026-07-16 6:28 ` sashiko-bot
2026-07-16 17:58 ` Bart Van Assche
2026-07-16 6:19 ` [PATCH 5/5] scsi: ufs: debugfs: Reserve space for a string terminator liqiang
2026-07-16 17:56 ` Bart Van Assche
2026-07-16 17:42 ` [PATCH 0/5] scsi: ufs: Fix descriptor parsing and invalid input handling Bart Van Assche
2026-07-17 15:16 ` Li Qiang
2026-07-17 15:39 ` [PATCH v2 0/6] " Li Qiang
2026-07-17 15:39 ` [PATCH v2 1/6] scsi: ufs: core: Validate string descriptors Li Qiang
2026-07-17 15:39 ` [PATCH v2 2/6] scsi: ufs: Avoid NULL CQE dereference when reporting invalid tags Li Qiang
2026-07-17 15:39 ` [PATCH v2 3/6] scsi: ufs: core: Validate connected lane counts Li Qiang
2026-07-17 16:21 ` sashiko-bot
2026-07-17 15:39 ` [PATCH v2 4/6] scsi: ufs: rpmb: Validate request frame length before parsing Li Qiang
2026-07-17 16:32 ` sashiko-bot
2026-07-17 15:39 ` [PATCH v2 5/6] scsi: ufs: rpmb: Use unaligned accessors for RPMB frames Li Qiang
2026-07-17 16:54 ` sashiko-bot [this message]
2026-07-17 15:39 ` [PATCH v2 6/6] scsi: ufs: debugfs: Reserve space for a string terminator Li Qiang
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=20260717165459.8F2091F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liqiang01@kylinos.cn \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox