From: <shao.mingyin@zte.com.cn>
To: <martin.petersen@oracle.com>, <alim.akhtar@samsung.com>,
<bvanassche@acm.org>, <linux-scsi@vger.kernel.org>
Cc: <james.bottomley@hansenpartnership.com>,
<peter.griffin@linaro.org>, <beanhuo@micron.com>,
<stanleyjhu@google.com>, <linux-samsung-soc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: [PATCH 0/2] scsi: ufs: fix an RPMB teardown cycle and a shift UB
Date: Tue, 3 Nov 2026 18:52:29 +0800 (CST) [thread overview]
Message-ID: <20261103185229490gmhePBF5_11x_thf4X-Rw@zte.com.cn> (raw)
Two independent fixes in the UFS stack, found while reading the probe and
remove paths and the task-management hooks.
Patch 1 is in the core RPMB glue. ufs_rpmb_probe() registers a child
device whose parent is the RPMB device, then registers an rpmb_dev on top
of it. device_add() takes a reference on the parent, and
rpmb_dev_unregister() is only called from ufs_rpmb_device_release(), i.e.
when that reference count drops to zero. The remove path and the probe
error path call device_unregister() on the child directly, so the
reference held by the rpmb_dev never goes away, the release callback never
runs, and the RPMB child stays registered while the devm-allocated
ufs_rpmb is freed together with the host. Unregister the rpmb_dev first,
as mmc_blk_remove_rpmb_part() does, and let the release callback tolerate
an already unregistered device.
Patch 2 is in the Exynos host driver. The nexus type masks are built with
(1 << tag); controllers can expose 32 unified task tags, and tag 31
shifts a 32-bit int into its sign bit. Commit 01aad16c2257 fixed the
same expression in exynos_ufs_post_link() and noted that the UTMRL access
should be changed as well, but the four remaining mask computations were
missed.
The patches share no code: patch 1 is the core RPMB glue, patch 2 is
confined to the Exynos host hooks, so they can be applied in any order and
need review from different people. Both carry Fixes: and Cc: stable.
Related work: an earlier series by Stanley Jhu ("scsi: ufs: rpmb: Fix bus
registration and device lifecycle", v3, September 2026) also calls
rpmb_dev_unregister() in ufs_rpmb_remove() to break the cyclic refcount, but
it is not in linux-next as of next-20261030. This patch is the narrower fix:
unregister the rpmb_dev before the child device and let release tolerate an
already unregistered device.
Testing: both apply to next-20261030, pass checkpatch.pl --strict with
0 errors/0 warnings/0 checks, and the two touched objects build with W=1.
There is no Exynos board and no RPMB device on this machine, so neither
path was exercised at runtime; both fixes come from code inspection.
Patch 2 is the easier one to confirm: with UBSAN enabled, tag 31 would
report shift-out-of-bounds before the patch.
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c
next reply other threads:[~2026-11-03 10:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 10:52 shao.mingyin [this message]
2026-11-03 10:52 ` [PATCH 1/2] scsi: ufs: core: unregister RPMB devices before their parent shao.mingyin
2026-11-03 10:52 ` [PATCH 2/2] scsi: ufs: exynos: use BIT() for the nexus type tag mask shao.mingyin
2026-11-03 17:51 ` [PATCH 0/2] scsi: ufs: fix an RPMB teardown cycle and a shift UB Bart Van Assche
2026-11-03 19:00 ` shao.mingyin
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=20261103185229490gmhePBF5_11x_thf4X-Rw@zte.com.cn \
--to=shao.mingyin@zte.com.cn \
--cc=alim.akhtar@samsung.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=peter.griffin@linaro.org \
--cc=stable@vger.kernel.org \
--cc=stanleyjhu@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
all inboxes | Powered by JetHome®