Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

rust: pwm: remove unsound Device::chip helper - #1275

Open
Franklin-Qi wants to merge 1 commit into
Rust-for-Linux:rust-nextfrom
Franklin-Qi:fix/pwm-device-chip-type-confusion
Open

Franklin-Qi wants to merge 1 commit into
Rust-for-Linux:rust-nextfrom
Franklin-Qi:fix/pwm-device-chip-type-confusion

Conversation

@Franklin-Qi

Copy link
Copy Markdown

Device::chip::() is a safe API that forges &Chip 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, and there are no in-tree callers of Device::chip. Remove the helper.

Fixes: d8046cd ("rust: pwm: Add complete abstraction layer")
Cc: stable@vger.kernel.org
Closes: #1274

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: d8046cd ("rust: pwm: Add complete abstraction layer")
Cc: stable@vger.kernel.org
Closes: Rust-for-Linux#1274

Signed-off-by: Franklin-Qi <yusq77@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

pwm: Device::chip allows safe Rust to reinterpret chip drvdata as the wrong type

1 participant