Re: [PATCH v3] coccinelle: locks: Add must_hold.cocci
From: Marco Elver
Date: Mon Nov 23 2026 - 11:28:41 EST
On Mon, 23 Nov 2026 at 17:26, Bart Van Assche <bvanassche@xxxxxxx> wrote:
>
> On 11/23/26 2:45 AM, Marco Elver wrote:
> > Clang's context analysis treats lockdep_assert_held*() as an assumption
> > that the lock is held. A function that asserts instead of being
> > annotated with __must_hold() therefore passes the analysis, but its
> > callers are never checked.
> >
> > Add a script that reports functions which assert on all paths that a
> > lock is held, where the lock can be named in a function attribute, and
> > which are not annotated with __must_hold*(), __releases*(),
> > __cond_releases*(), __context_unsafe() or __no_context_analysis. A lock
> > can be named if all identifiers in the lock expression are parameters or
> > member names, or if it is a global of the form &name or &name.member.
> > Functions that mention the lock before asserting it, e.g. to acquire it,
> > are skipped.
>
> Bart Van Assche <bvanassche@xxxxxxx>
Thanks!
Ack or Reviewed-by?
Aside, do coccinelle scripts go through a specific tree?
Otherwise, I might just take it through the -kcsan tree.