From: Franklin-Qi <yusq77@gmail.com>
To: "Michal Wilczynski" <m.wilczynski@samsung.com>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Danilo Krummrich" <dakr@kernel.org>
Cc: "Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
linux-pwm@vger.kernel.org, rust-for-linux@vger.kernel.org,
stable@vger.kernel.org, Franklin-Qi <yusq77@gmail.com>
Subject: [PATCH] rust: pwm: remove unsound Device::chip helper
Date: Thu, 3 Dec 2026 18:42:41 +0800 [thread overview]
Message-ID: <20261203104241.101453-1-yusq77@gmail.com> (raw)
Device::chip::<T>() is a safe API that forges &Chip<T> for an
arbitrary PwmOps type, after which Chip::drvdata() reinterprets the
chip private allocation as &T. Callers can therefore type-confuse
drvdata from safe Rust; with a larger forged T this is a slab
out-of-bounds read under KASAN.
PwmOps callbacks already receive a correctly typed &Chip<Self>, and
there are no in-tree callers of Device::chip. Remove the helper.
Fixes: d8046cd50879 ("rust: pwm: Add complete abstraction layer")
Cc: stable@vger.kernel.org
Closes: https://github.com/Rust-for-Linux/linux/issues/1274
Signed-off-by: Franklin-Qi <yusq77@gmail.com>
---
rust/kernel/pwm.rs | 8 --------
1 file changed, 8 deletions(-)
diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs
index 8aa47304bec3..4cb5a15d0d8e 100644
--- a/rust/kernel/pwm.rs
+++ b/rust/kernel/pwm.rs
@@ -101,14 +101,6 @@ pub fn hwpwm(&self) -> u32 {
unsafe { (*self.as_raw()).hwpwm }
}
- /// Gets a reference to the parent `Chip` that this device belongs to.
- pub fn chip<T: PwmOps>(&self) -> &Chip<T> {
- // SAFETY: `self.as_raw()` provides a valid pointer. (*self.as_raw()).chip
- // is assumed to be a valid pointer to `pwm_chip` managed by the kernel.
- // Chip::from_raw's safety conditions must be met.
- unsafe { Chip::<T>::from_raw((*self.as_raw()).chip) }
- }
-
/// Gets the label for this PWM device, if any.
pub fn label(&self) -> Option<&CStr> {
// SAFETY: self.as_raw() provides a valid pointer.
--
2.55.0
reply other threads:[~2026-12-03 10:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261203104241.101453-1-yusq77@gmail.com \
--to=yusq77@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=linux-pwm@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=m.wilczynski@samsung.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=ukleinek@kernel.org \
--cc=work@onurozkan.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