[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260120072401.GA5905@lst.de>
Date: Tue, 20 Jan 2026 08:24:01 +0100
From: Christoph Hellwig <hch@....de>
To: Marco Elver <elver@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, Will Deacon <will@...nel.org>,
Boqun Feng <boqun.feng@...il.com>, Waiman Long <longman@...hat.com>,
Christoph Hellwig <hch@....de>,
Steven Rostedt <rostedt@...dmis.org>,
Bart Van Assche <bvanassche@....org>, kasan-dev@...glegroups.com,
llvm@...ts.linux.dev, linux-crypto@...r.kernel.org,
linux-doc@...r.kernel.org, linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH tip/locking/core 0/6] compiler-context-analysis: Scoped
init guards
On Mon, Jan 19, 2026 at 10:05:50AM +0100, Marco Elver wrote:
> Note: Scoped guarded initialization remains optional, and normal
> initialization can still be used if no guarded members are being
> initialized. Another alternative is to just disable context analysis to
> initialize guarded members with `context_unsafe(var = init)` or adding
> the `__context_unsafe(init)` function attribute (the latter not being
> recommended for non-trivial functions due to lack of any checking):
I still think this is doing the wrong for the regular non-scoped
cased, and I think I finally understand what is so wrong about it.
The fact that mutex_init (let's use mutexes for the example, applied
to other primitives as well) should not automatically imply guarding
the members for the rest of the function. Because as soon as the
structure that contains the lock is published that is not actually
true, and we did have quite a lot of bugs because of that in the
past.
So I think the first step is to avoid implying the safety of guarded
member access by initialing the lock. We then need to think how to
express they are save, which would probably require explicit annotation
unless we can come up with a scheme that makes these accesses fine
before the mutex_init in a magic way.
Powered by blists - more mailing lists