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: <31804bbf-1a0b-4312-8db6-532a008528a2@gmail.com>
Date: Thu, 26 Jun 2025 18:40:06 +0100
From: Igor Korotin <igor.korotin.linux@...il.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: "Rafael J . Wysocki" <rafael@...nel.org>,
 Alex Gaynor <alex.gaynor@...il.com>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Miguel Ojeda <ojeda@...nel.org>, Rob Herring <robh@...nel.org>,
 Saravana Kannan <saravanak@...gle.com>, Alex Hung <alex.hung@....com>,
 Andrew Morton <akpm@...ux-foundation.org>, Jakub Kicinski <kuba@...nel.org>,
 Jonathan Cameron <Jonathan.Cameron@...wei.com>,
 Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
 Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
 Remo Senekowitsch <remo@...nzli.dev>, Tamir Duberstein <tamird@...il.com>,
 Viresh Kumar <viresh.kumar@...aro.org>,
 Wedson Almeida Filho <wedsonaf@...il.com>,
 Xiangfei Ding <dingxiangfei2009@...il.com>, devicetree@...r.kernel.org,
 linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
 rust-for-linux@...r.kernel.org, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, Alice Ryhl <aliceryhl@...gle.com>,
 Andreas Hindborg <a.hindborg@...nel.org>, Benno Lossin <lossin@...nel.org>,
 Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
 Len Brown <lenb@...nel.org>, Trevor Gross <tmgross@...ch.edu>
Subject: Re: [PATCH v8 4/9] rust: acpi: add `acpi::DeviceId` abstraction



On 6/26/25 16:25, Danilo Krummrich wrote:
> On 6/20/25 5:24 PM, 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<const N: usize>(id: &[u8; N]) -> Self {
> 
> Didn't notice before, but why was this silently changed from &CStr to
> &[u8; N]
> from v6 to v7?
> 
>> +        build_assert!(N <= Self::ACPI_ID_LEN, "ID exceeds 16 bytes");
>> +        // 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() };
>> +        let mut i = 0;
>> +        while i < N {
>> +            acpi.id[i] = id[i];
>> +            i += 1;
>> +        }
>> +
>> +        Self(acpi)
>> +    }
>> +}

In v6 I was asked to change assert! (runtime) to build_assert! (build time)
It was as follows:

> +    pub const fn new(id: &'static CStr) -> Self {
> +        assert!(id.len() <= Self::ACPI_ID_LEN, "ID exceeds 16 bytes");

but id.len() breaks const context and so build_assert! triggers
assertion. If I needed to explicitly describe change from CStr to
[u8;20], then it's my bad.

Thanks,
Igor

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ