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] [day] [month] [year] [list]
Message-ID: <aMJClvnT6O5WrcCD@tardis.local>
Date: Wed, 10 Sep 2025 20:31:34 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Benno Lossin <lossin@...nel.org>
Cc: Alice Ryhl <aliceryhl@...gle.com>, Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...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>, Tejun Heo <tj@...nel.org>,
	Tamir Duberstein <tamird@...il.com>,
	Dirk Behme <dirk.behme@...il.com>, Alban Kurti <kurti@...icto.ai>,
	Fiona Behrens <me@...enk.dev>, rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] rust: pin-init: add pin projections to `#[pin_data]`

On Wed, Sep 10, 2025 at 02:18:12PM +0200, Benno Lossin wrote:
> On Wed Sep 10, 2025 at 12:54 PM CEST, Alice Ryhl wrote:
> > On Wed, Sep 10, 2025 at 12:38 PM Benno Lossin <lossin@...nel.org> wrote:
> >>
> >> On Wed Sep 10, 2025 at 12:23 PM CEST, Alice Ryhl wrote:
> >> > On Fri, Sep 5, 2025 at 7:12 PM Benno Lossin <lossin@...nel.org> wrote:
> >> >> +    (make_pin_projections:
> >> >> +        @vis($vis:vis),
> >> >> +        @name($name:ident),
> >> >> +        @impl_generics($($impl_generics:tt)*),
> >> >> +        @ty_generics($($ty_generics:tt)*),
> >> >> +        @decl_generics($($decl_generics:tt)*),
> >> >> +        @where($($whr:tt)*),
> >> >> +        @pinned($($(#[$($p_attr:tt)*])* $pvis:vis $p_field:ident : $p_type:ty),* $(,)?),
> >> >> +        @not_pinned($($(#[$($attr:tt)*])* $fvis:vis $field:ident : $type:ty),* $(,)?),
> >> >> +    ) => {
> >> >> +        $crate::macros::paste! {
> >> >> +            #[doc(hidden)]
> >> >> +            $vis struct [< $name Projection >] <'__pin, $($decl_generics)*> {
> >> >
> >> > I'm not sure we want $vis here. That's the visibility of the original
> >> > struct, but I don't think we want it to be pub just because the struct
> >> > is.
> >>
> >> Why shouldn't it be pub if the original is pub? I don't really
> >> understand the concern, since the fields themselves will still have the
> >> correct visibility. Additionally, there is the `___pin_phantom_data`
> >> field that's always private, so you cannot construct this outside of the
> >> module.
> >
> > I mean, for instance, it's going to mean that every single struct that
> > wraps Opaque in a private field will get a useless pub function called
> > project that will appear in html docs.
> 
> It's `#[doc(hidden)]` :)
> 
> > Pin-project limits the visibility to pub(crate) when the struct is pub.
> 
> I think I would have to look inside the `vis` to recreate that behavior,
> so I'd rather do it as a future patch. Thoughts?
> 

This reminds me: I think should make these functions `#[inline]` for
now? (Until we make a decision about whether it's pub(crate) or $vis)

Otherwise compiler will generate functions in kernel binaries for some
of them. E.g.

nm .kunit/vmlinux.o  | rustfilt | grep project
00000000002449cc T <kernel::sync::LockClassKey>::project
000000000023ef40 T <kernel::sync::completion::Completion>::project
000000000023ef40 T <kernel::sync::poll::PollCondVar>::project
0000000000244994 T <kernel::sync::condvar::CondVar>::project
0000000000260a68 T <doctests_kernel_generated::rust_doctest_kernel_init_rs_3::main::_doctest_main____rust_kernel_init_rs_69_0::RawFoo>::project
0000000000008b70 d __UNIQUE_ID___addressable__RNvMs0_NtCshc5sK6KjdJJ_6kernel4syncNtB5_12LockClassKey7project2007
0000000000008c98 d __UNIQUE_ID___addressable__RNvMs1_NtNtCshc5sK6KjdJJ_6kernel4sync10completionNtB5_10Completion7project2044
0000000000008ca0 d __UNIQUE_ID___addressable__RNvMs1_NtNtCshc5sK6KjdJJ_6kernel4sync4pollNtB5_11PollCondVar7project2045
0000000000008b60 d __UNIQUE_ID___addressable__RNvMs1_NtNtCshc5sK6KjdJJ_6kernel4sync7condvarNtB5_7CondVar7project2005
0000000000010d28 r __export_symbol_<kernel::sync::LockClassKey>::project
0000000000010f78 r __export_symbol_<kernel::sync::completion::Completion>::project
0000000000010f88 r __export_symbol_<kernel::sync::poll::PollCondVar>::project
0000000000010d08 r __export_symbol_<kernel::sync::condvar::CondVar>::project

Otherwise the patch looks good to me. Feel free to add:

Reviewed-by: Boqun Feng <boqun.feng@...il.com>

Regards,
Boqun

> ---
> Cheers,
> Benno

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ