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: <20231020.215448.1421599168007259810.fujita.tomonori@gmail.com>
Date: Fri, 20 Oct 2023 21:54:48 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: benno.lossin@...ton.me
Cc: fujita.tomonori@...il.com, netdev@...r.kernel.org,
 rust-for-linux@...r.kernel.org, andrew@...n.ch,
 miguel.ojeda.sandonis@...il.com, tmgross@...ch.edu, boqun.feng@...il.com,
 wedsonaf@...il.com, greg@...ah.com
Subject: Re: [PATCH net-next v5 1/5] rust: core abstractions for network
 PHY drivers

On Fri, 20 Oct 2023 09:34:46 +0900 (JST)
FUJITA Tomonori <fujita.tomonori@...il.com> wrote:

> On Thu, 19 Oct 2023 15:20:51 +0000
> Benno Lossin <benno.lossin@...ton.me> wrote:
> 
>> I would like to remove the mutable static variable and simplify
>> the macro.
> 
> How about adding DriverVTable array to Registration?
> 
> /// Registration structure for a PHY driver.
> ///
> /// # Invariants
> ///
> /// The `drivers` slice are currently registered to the kernel via `phy_drivers_register`.
> pub struct Registration<const N: usize> {
>     drivers: [DriverVTable; N],
> }
> 
> impl<const N: usize> Registration<{ N }> {
>     /// Registers a PHY driver.
>     pub fn register(
>         module: &'static crate::ThisModule,
>         drivers: [DriverVTable; N],
>     ) -> Result<Self> {
>         let mut reg = Registration { drivers };
>         let ptr = reg.drivers.as_mut_ptr().cast::<bindings::phy_driver>();
>         // SAFETY: The type invariants of [`DriverVTable`] ensure that all elements of the `drivers` slice
>         // are initialized properly. So an FFI call with a valid pointer.
>         to_result(unsafe {
>             bindings::phy_drivers_register(ptr, reg.drivers.len().try_into()?, module.0)
>         })?;
>         // INVARIANT: The `drivers` slice is successfully registered to the kernel via `phy_drivers_register`.
>         Ok(reg)
>     }
> }

Scratch this.

This doesn't work. Also simply putting slice of DriverVTable into
Module strcut doesn't work.

We cannot move a slice of DriverVTable. Except for static allocation,
is there a simple way?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ