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: <D7735793-D99E-44D4-945C-2AC0B500E1F9@collabora.com>
Date: Thu, 10 Jul 2025 10:33:50 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>,
 Alex Gaynor <alex.gaynor@...il.com>,
 Boqun Feng <boqun.feng@...il.com>,
 Gary Guo <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>,
 Andreas Hindborg <a.hindborg@...nel.org>,
 Trevor Gross <tmgross@...ch.edu>,
 Danilo Krummrich <dakr@...nel.org>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 "Rafael J. Wysocki" <rafael@...nel.org>,
 Andrew Morton <akpm@...ux-foundation.org>,
 Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
 Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
 Bjorn Helgaas <bhelgaas@...gle.com>,
 Mika Westerberg <mika.westerberg@...ux.intel.com>,
 Ying Huang <huang.ying.caritas@...il.com>,
 Benno Lossin <lossin@...nel.org>,
 linux-kernel@...r.kernel.org,
 rust-for-linux@...r.kernel.org,
 Fiona Behrens <me@...enk.dev>
Subject: Re: [PATCH v12 1/3] rust: io: add resource abstraction

[…]

> 
>> +    }
>> +
>> +    /// Returns the name of the resource.
>> +    pub fn name(&self) -> &'static CStr {
>> +        let inner = self.0.get();
>> +        // SAFETY: safe as per the invariants of `Resource`
>> +        unsafe { CStr::from_char_ptr((*inner).name) }
>> +    }
>> +
>> +    /// Returns the flags associated with the resource.
>> +    pub fn flags(&self) -> Flags {
>> +        let inner = self.0.get();
>> +        // SAFETY: safe as per the invariants of `Resource`
>> +        let flags = unsafe { *inner }.flags;
>> +
>> +        Flags(flags)
>> +    }
>> +}
>> +
>> +// SAFETY: `Resource` only holds a pointer to a C `struct resource`, which is
>> +// safe to be used from any thread.
>> +unsafe impl Send for Resource {}
>> +
>> +// SAFETY: `Resource` only holds a pointer to a C `struct resource`, references
>> +// to which are safe to be used from any thread.
>> +unsafe impl Sync for Resource {}
>> +
>> +/// Resource flags as stored in the C `struct resource::flags` field.
>> +///
>> +/// They can be combined with the operators `|`, `&`, and `!`.
>> +///
>> +/// Values can be used from the [`flags`] module.
>> +#[derive(Clone, Copy, PartialEq)]
>> +pub struct Flags(usize);
> 
> Based on usage it looks like the correct type is c_int?

Shouldn’t this be c_ulong because of:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct resource {
    pub start: resource_size_t,
    pub end: resource_size_t,
    pub name: *const ffi::c_char,
    pub flags: ffi::c_ulong, <——

In any case, we will have to cast this because __request_region
expects c_int.

— Daniel


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ