lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DAGZIHBVBI6Z.32401TQB5MNTL@kernel.org>
Date: Sun, 08 Jun 2025 09:48:00 +0200
From: "Benno Lossin" <lossin@...nel.org>
To: "Igor Korotin" <igor.korotin.linux@...il.com>, <ojeda@...nel.org>,
 <alex.gaynor@...il.com>, <rafael@...nel.org>, <gregkh@...uxfoundation.org>,
 <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>,
 <linux-acpi@...r.kernel.org>
Cc: <boqun.feng@...il.com>, <gary@...yguo.net>, <bjorn3_gh@...tonmail.com>,
 <benno.lossin@...ton.me>, <a.hindborg@...nel.org>, <aliceryhl@...gle.com>,
 <tmgross@...ch.edu>, <dakr@...nel.org>, <lenb@...nel.org>,
 <wedsonaf@...il.com>, <viresh.kumar@...aro.org>, <alex.hung@....com>,
 <dingxiangfei2009@...il.com>
Subject: Re: [PATCH v3 1/4] rust: acpi: add `acpi::DeviceId` abstraction

On Fri Jun 6, 2025 at 7:06 PM CEST, Igor Korotin wrote:
> +impl DeviceId {
> +    const ACPI_ID_LEN: usize = 16;
> +
> +    /// Create a new device id from an ACPI 'id' string.
> +    pub const fn new(id: &'static CStr) -> Self {
> +        assert!(id.len() <= Self::ACPI_ID_LEN, "ID exceeds 16 bytes");
> +        let src = id.as_bytes_with_nul();
> +        // Replace with `bindings::acpi_device_id::default()` once stabilized for `const`.
> +        // SAFETY: FFI type is valid to be zero-initialized.
> +        let mut acpi: bindings::acpi_device_id = unsafe { core::mem::zeroed() };

This can be made safe using this series:

    https://lore.kernel.org/all/20250523145125.523275-1-lossin@kernel.org

---
Cheers,
Benno

> +        let mut i = 0;
> +        while i < src.len() {
> +            acpi.id[i] = src[i];
> +            i += 1;
> +        }
> +
> +        Self(acpi)
> +    }
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ