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: <CANpmjNPDnFHr9yu1n9Sw3K+sqSfQoM-OHm6vmgjrfVaGMNHmOQ@mail.gmail.com>
Date: Thu, 22 Jan 2026 10:15:10 +0100
From: Marco Elver <elver@...gle.com>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Christoph Hellwig <hch@....de>, 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>, linux-kernel@...r.kernel.org, llvm@...ts.linux.dev, 
	Bart Van Assche <bvanassche@....org>
Subject: Re: [PATCH tip/locking/core] compiler-context-analysis: Support
 immediate acquisition after initialization

On Thu, 22 Jan 2026 at 02:24, Steven Rostedt <rostedt@...dmis.org> wrote:
>
> On Fri, 16 Jan 2026 16:47:54 +0100
> Peter Zijlstra <peterz@...radead.org> wrote:
>
> > struct obj {
> >       spinlock_t      lock;
> >       int             state __guarded_by(lock);
> > };
> >
> > struct obj *create_obj(void)
> > {
> >       struct obj *obj = kzmalloc(sizeof(*obj), GFP_KERNEL);
> >       if (!obj)
> >               return NULL;
> >
> >       spin_lock_init(&obj->lock);
> >       obj->state = INIT_STATE; // error: ->state demands ->lock is held
> > }
>
> I haven't seen all the other approaches, but would a macro be able to hide
> it with some kind of obfuscation from the compiler?
>
>
>         GUARD_INIT(obj->state, INIT_STATE);
>
> which would be something like a WRITE_ONCE() macro. I'm not sure what
> tooling there is to disable checks for a small bit of code like this.

Something like this is now a documented alternative [1]. Basically this works:

   context_unsafe(obj->state = INIT_STATE);

For single guarded fields, that's as simple as it gets.

[1] https://lore.kernel.org/all/20260119094029.1344361-1-elver@google.com/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ