From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF9B2D7DC3; Thu, 11 Dec 2025 09:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765446953; cv=none; b=Kw6eEiRluVNAM7ysl0Xv/ebDsm5m41Yv2lC6uqEBfTwCULDsV124XpjEHw4ozf6o+3dh1YG/KtaQ/YnbM0vyIpCUc9Q8Z6sM8J1S9h2qYW0Ww3E1oYntlAgLV0VTcdSg4/e9KP6iqddMIDVjgGw2dfIjADcdAxDN6I/Qi45LD4M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765446953; c=relaxed/simple; bh=9lSRlga72l9+gIoIAFVVo5cVfTqtz+9+i4a8Tut3XNw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S4375qIbcn6/CgfHynRFjAwPCcvNJXWVsc0ccX0rZoSI73A0788mfoltXjDxaBmWDIIzQFSravpSLhwGeZIPB1strTfz5w+yb1eEt05jKbhDjbCKQXlWDWcpGpcZ8AW3l1MaRNw9b2BFp0E5HIuM+kidgA6JdUO8n8uZVoFkis4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=E3bZKCI1; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="E3bZKCI1" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6WhymY9DTx4lwYH2yf2+tZtBM6CKMmmYYDOh50+lOZo=; b=E3bZKCI1ZZXvnG0+gAKKjTRe88 LDQhz432e77NUYPNQQnmOHIWVO75MWPvr+x9ii68maqX/F62HbYRmLDcK9GnRB3g2hCqIlCL1j90u m956FTwbPf8++wE5dZatnhW5YgU7HRVcZYJvhtfJkX7EGXEyA/vhdvAxzQDui+P7LA/NobcKpZEWn mCV2u3O0fxZKBdjE8/9IO7ypAIf+PQI4Y+d+TeggMyq3EiRF7Ltrowsn0AY9bpVjEHVBe3MnLCr82 uMOArrHQRtzlLPKJrj4S4qkLHV2+GWAHKrDfPnPMJXuULb9wLKbzCe1Ukoo7LCvMNsrowOCD1pN5C /h/oVIJA==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vTcWn-0000000Eibk-2SDe; Thu, 11 Dec 2025 09:00:02 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id DB9BD300566; Thu, 11 Dec 2025 10:55:16 +0100 (CET) Date: Thu, 11 Dec 2025 10:55:16 +0100 From: Peter Zijlstra To: Marco Elver Cc: Boqun Feng , Ingo Molnar , Will Deacon , "David S. Miller" , Luc Van Oostenryck , Chris Li , "Paul E. McKenney" , Alexander Potapenko , Arnd Bergmann , Bart Van Assche , Christoph Hellwig , Dmitry Vyukov , Eric Dumazet , Frederic Weisbecker , Greg Kroah-Hartman , Herbert Xu , Ian Rogers , Jann Horn , Joel Fernandes , Johannes Berg , Jonathan Corbet , Josh Triplett , Justin Stitt , Kees Cook , Kentaro Takeda , Lukas Bulwahn , Mark Rutland , Mathieu Desnoyers , Miguel Ojeda , Nathan Chancellor , Neeraj Upadhyay , Nick Desaulniers , Steven Rostedt , Tetsuo Handa , Thomas Gleixner , Thomas Graf , Uladzislau Rezki , Waiman Long , kasan-dev@googlegroups.com, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, linux-sparse@vger.kernel.org, linux-wireless@vger.kernel.org, llvm@lists.linux.dev, rcu@vger.kernel.org Subject: Re: [PATCH v4 06/35] cleanup: Basic compatibility with context analysis Message-ID: <20251211095516.GO3707837@noisy.programming.kicks-ass.net> References: <20251120145835.3833031-2-elver@google.com> <20251120151033.3840508-7-elver@google.com> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251120151033.3840508-7-elver@google.com> On Thu, Nov 20, 2025 at 04:09:31PM +0100, Marco Elver wrote: > Introduce basic compatibility with cleanup.h infrastructure: introduce > DECLARE_LOCK_GUARD_*_ATTRS() helpers to add attributes to constructors > and destructors respectively. > > Note: Due to the scoped cleanup helpers used for lock guards wrapping > acquire and release around their own constructors/destructors that store > pointers to the passed locks in a separate struct, we currently cannot > accurately annotate *destructors* which lock was released. While it's > possible to annotate the constructor to say which lock was acquired, > that alone would result in false positives claiming the lock was not > released on function return. > > Instead, to avoid false positives, we can claim that the constructor > "assumes" that the taken lock is held via __assumes_ctx_guard(). > > This will ensure we can still benefit from the analysis where scoped > guards are used to protect access to guarded variables, while avoiding > false positives. The only downside are false negatives where we might > accidentally lock the same lock again: > > raw_spin_lock(&my_lock); > ... > guard(raw_spinlock)(&my_lock); // no warning > > Arguably, lockdep will immediately catch issues like this. > > While Clang's analysis supports scoped guards in C++ [1], there's no way > to apply this to C right now. Better support for Linux's scoped guard > design could be added in future if deemed critical. Moo, so the alias analysis didn't help here?