Re: [PATCH] rust: configfs: initialize AttributeList at compile time without UnsafeCell
From: Andreas Hindborg
Date: Mon Nov 30 2026 - 11:00:15 EST
Andreas Hindborg <a.hindborg@xxxxxxxxxx> writes:
> Hi Bilal,
>
> "Bilal Hashim" <AeeSec@xxxxxxx> writes:
>
>> The configfs_attrs! macro currently declares a global static AttributeList
>> wrapping an UnsafeCell<[*mut c_void; N]> and populates it at runtime via
>> AttributeList::add() on every macro invocation.
>>
>> Although the static identifier is lexically scoped inside the macro block,
>> the static storage is globally shared across all invocations and threads.
>> When a function invoking configfs_attrs! (such as make_group() in
>> drivers/block/rnull/configfs.rs) executes concurrently on multiple
>> threads, or while C configfs concurrently reads ct_attrs_const, the
>> unsynchronized &mut writes into the static UnsafeCell cause aliasing UB
>> and a data race.
>>
>> Replace UnsafeCell and the runtime AttributeList::add() calls with a pure
>> const AttributeList initialized at compile time inside the static item.
>> This eliminates the data race, removes the runtime pointer stores from
>> make_group(), and allows the attribute table to reside in read-only
>> memory.
>
> Thanks for the patch!
You should also include these people in the Cc list:
Boqun Feng <boqun@xxxxxxxxxx> (reviewer:RUST)
Gary Guo <gary@xxxxxxxxxxx> (reviewer:RUST)
"Björn Roy Baron" <bjorn3_gh@xxxxxxxxxxxxxx> (reviewer:RUST)
Benno Lossin <lossin@xxxxxxxxxx> (reviewer:RUST)
Alice Ryhl <aliceryhl@xxxxxxxxxx> (reviewer:RUST)
Trevor Gross <tmgross@xxxxxxxxx> (reviewer:RUST)
Danilo Krummrich <dakr@xxxxxxxxxx> (reviewer:RUST)
Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx> (reviewer:RUST)
Tamir Duberstein <tamird@xxxxxxxxxx> (reviewer:RUST)
Alexandre Courbot <acourbot@xxxxxxxxxx> (reviewer:RUST)
"Onur Özkan" <work@xxxxxxxxxxxxx> (reviewer:RUST)
You can use scripts/get_maintainer.pl to get the list.
I would encourage you to use the `b4` tool to submit patches. It
automates a lot of the stuff that people often get wrong [1].
Best regards,
Andreas Hindborg
[1] https://b4.docs.kernel.org/en/latest/