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]
Date: Tue, 02 Apr 2024 14:52:49 +0200
From: Andreas Hindborg <nmi@...aspace.dk>
To: Benno Lossin <benno.lossin@...ton.me>
Cc: Jens Axboe <axboe@...nel.dk>,  Christoph Hellwig <hch@....de>,  Keith
 Busch <kbusch@...nel.org>,  Damien Le Moal <Damien.LeMoal@....com>,  Bart
 Van Assche <bvanassche@....org>,  Hannes Reinecke <hare@...e.de>,
  "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,  Andreas
 Hindborg <a.hindborg@...sung.com>,  Niklas Cassel <Niklas.Cassel@....com>,
  Greg KH <gregkh@...uxfoundation.org>,  Matthew Wilcox
 <willy@...radead.org>,  Miguel Ojeda <ojeda@...nel.org>,  Alex Gaynor
 <alex.gaynor@...il.com>,  Wedson Almeida Filho <wedsonaf@...il.com>,
  Boqun Feng <boqun.feng@...il.com>,  Gary Guo <gary@...yguo.net>,
  Björn
 Roy Baron <bjorn3_gh@...tonmail.com>,  Alice Ryhl <aliceryhl@...gle.com>,
  Chaitanya Kulkarni <chaitanyak@...dia.com>,  Luis Chamberlain
 <mcgrof@...nel.org>,  Yexuan Yang <1182282462@...t.edu.cn>,  Sergio
 González Collado <sergio.collado@...il.com>,  Joel
 Granados
 <j.granados@...sung.com>,  "Pankaj Raghav (Samsung)"
 <kernel@...kajraghav.com>,  Daniel Gomez <da.gomez@...sung.com>,  open
 list <linux-kernel@...r.kernel.org>,  "rust-for-linux@...r.kernel.org"
 <rust-for-linux@...r.kernel.org>,  "lsf-pc@...ts.linux-foundation.org"
 <lsf-pc@...ts.linux-foundation.org>,  "gost.dev@...sung.com"
 <gost.dev@...sung.com>
Subject: Re: [RFC PATCH 4/5] rust: block: add rnull, Rust null_blk
 implementation

Benno Lossin <benno.lossin@...ton.me> writes:

> On 3/13/24 12:05, Andreas Hindborg wrote:
>> +module! {
>> +    type: NullBlkModule,
>> +    name: "rnull_mod",
>> +    author: "Andreas Hindborg",
>> +    license: "GPL v2",
>> +    params: {
>> +        param_memory_backed: bool {
>> +            default: true,
>> +            permissions: 0,
>> +            description: "Use memory backing",
>> +        },
>> +        // Problems with pin_init when `irq_mode`
>
> Can you elaborate?

I think we discussed this before, but I do not recall what you decided
was the issue.

It is probably easier if you can apply the patches and try to build with
this on top:

diff --git a/drivers/block/rnull.rs b/drivers/block/rnull.rs
index 04bdb6668558..bd089c5e6e89 100644
--- a/drivers/block/rnull.rs
+++ b/drivers/block/rnull.rs
@@ -48,7 +48,7 @@
             description: "Use memory backing",
         },
         // Problems with pin_init when `irq_mode`
-        param_irq_mode: u8 {
+        irq_mode: u8 {
             default: 0,
             permissions: 0,
             description: "IRQ Mode (0: None, 1: Soft, 2: Timer)",
@@ -101,7 +101,7 @@ fn add_disk(tagset: Arc<TagSet<NullBlkDevice>>) -> Result<GenDisk<NullBlkDevice>
         return Err(kernel::error::code::EINVAL);
     }
 
-    let irq_mode = (*param_irq_mode.read()).try_into()?;
+    let irq_mode = (*irq_mode.read()).try_into()?;
 
     let queue_data = Box::pin_init(pin_init!(
         QueueData {

---

There is some kind of name clash issue when using `pin_init!` in the expression on
line 106:

    let queue_data = Box::pin_init(pin_init!(
        QueueData {
            tree <- TreeContainer::new(),
            completion_time_nsec: *param_completion_time_nsec.read(),
            irq_mode,
            memory_backed: *param_memory_backed.read(),
            block_size,
        }
    ))?;

I cannot immediately decipher the error message:

  RUSTC [M] drivers/block/rnull.o
error[E0277]: the trait bound `__rnull_mod_irq_mode: From<u8>` is not satisfied
   --> /home/aeh/src/linux-rust/linux/drivers/block/rnull.rs:104:39
    |
104 |     let irq_mode = (*irq_mode.read()).try_into()?;
    |                                       ^^^^^^^^ the trait `From<u8>` is not implemented for `__rnull_mod_irq_mode`
    |
    = note: required for `u8` to implement `Into<__rnull_mod_irq_mode>`
    = note: required for `__rnull_mod_irq_mode` to implement `TryFrom<u8>`
    = note: required for `u8` to implement `TryInto<__rnull_mod_irq_mode>`

error[E0308]: mismatched types
    --> /home/aeh/src/linux-rust/linux/drivers/block/rnull.rs:106:36
     |
106  |       let queue_data = Box::pin_init(pin_init!(
     |  ____________________________________^
107  | |         QueueData {
108  | |             tree <- TreeContainer::new(),
109  | |             completion_time_nsec: *param_completion_time_nsec.read(),
..    |
113  | |         }
114  | |     ))?;
     | |     ^
     | |     |
     | |_____expected `IRQMode`, found `__rnull_mod_irq_mode`
     |       arguments to this function are incorrect
     |
note: function defined here
    --> /home/aeh/.rustup/toolchains/1.74.1-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1365:21
     |
1365 | pub const unsafe fn write<T>(dst: *mut T, src: T) {
     |                     ^^^^^
     = note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `pin_init` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> /home/aeh/src/linux-rust/linux/drivers/block/rnull.rs:106:36
    |
39  | / module! {
40  | |     type: NullBlkModule,
41  | |     name: "rnull_mod",
42  | |     author: "Andreas Hindborg",
..   |
71  | |     },
72  | | }
    | |_- constant defined here
..
106 |       let queue_data = Box::pin_init(pin_init!(
    |  ____________________________________^
    | |____________________________________|
    | |____________________________________|
    | |____________________________________|
    | |
107 | |         QueueData {
108 | |             tree <- TreeContainer::new(),
109 | |             completion_time_nsec: *param_completion_time_nsec.read(),
..   |
113 | |         }
114 | |     ))?;
    | |     ^
    | |_____|
    | |_____expected `DropGuard<IRQMode>`, found `__rnull_mod_irq_mode`
    | |_____this expression has type `DropGuard<IRQMode>`
    | |_____`irq_mode` is interpreted as a constant, not a new binding
    |       help: introduce a new binding instead: `other_irq_mode`
    |
    = note: expected struct `DropGuard<IRQMode>`
               found struct `__rnull_mod_irq_mode`
    = note: this error originates in the macro `$crate::__init_internal` which comes from the expansion of the macro `pin_init` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
make[5]: *** [/home/aeh/src/linux-rust/linux/scripts/Makefile.build:293: drivers/block/rnull.o] Error 1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ