Skip to content

C sync_locks/io/alloc rules miss kernel vocabulary (spin_lock*, mutex_lock, readl/writel, kmalloc/kfree): kernel C reads as lock- and I/O-free #8016

Closed

Description

@squid-protocol

Problem

C's sync_locks and io rules only know the C11 / POSIX vocabulary, so kernel-style C reads as lock-free and I/O-free.

On main (patterns from languages/c.py):

code sync_locks io
pthread_mutex_lock(&m) ✓ —
spin_lock_irqsave(l, flags) ✗ —
mutex_lock(&m) ✗ —
data = readl_relaxed(base) — ✗
writel_relaxed(data, base) — ✗

Why it matters: in the v2.12.0 population DB, the 3rd most common function fingerprint (1.4% of all functions) is kernel-driver C. It is 77% from one repo, 1% tests, median 23 lines. Its fingerprint shows no def_sync_locks and no arch_io, even on functions that take a spinlock and write hardware registers (e.g. drivers/clk/mmp/clk-apmu.c: clk_apmu_enable).

Class to sweep

The kernel / BSD / RTOS vocabulary is missing from:

  • sync_locks: spin_lock*, mutex_lock / mutex_unlock, rcu_read_lock, down / up, raw_spin_lock*, FreeBSD mtx_lock (already present), sx_xlock, rw_rlock.
  • io: MMIO readl / writel / ioread32 / iowrite32 (and the _relaxed forms), inb / outb, copy_to_user / copy_from_user, bus_space_read_*.
  • cleanup, memory_alloc: kfree, kmalloc, kzalloc, devm_*, vfree. Check them; malloc / free are covered.

Each needs a per-language rule test. Goldens and the estate baselines may move.

Related: #8010 (rule overlap), #8009 (display names).

Activity

  1. added
    bug
    core-engine
    scope:sweep
    on Nov 7, 2026
  2. squid-protocol commented on Nov 7, 2026

    @squid-protocol
    OwnerAuthor

    Same class, Windows / ReactOS C: InterlockedIncrement / InterlockedDecrement / InterlockedCompareExchange match neither C concurrency nor sync_locks (the C# rule already lists Interlocked). Seen in the 6th most common population fingerprint (static C COM methods, e.g. ReactOS IDirectPlay4Impl_AddRef). Add EnterCriticalSection / AcquireSRWLock* / WaitForSingleObject to the sweep too.

  3. squid-protocol commented on Nov 8, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-08T23:04Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  4. squid-protocol commented on Nov 8, 2026

    @squid-protocol
    OwnerAuthor

    Closed by #8139: C sync_locks/io/memory_alloc/cleanup/concurrency now cover the kernel/BSD/Windows vocabulary, with tests. C++/ObjC sibling check is noted in the PR; no burned estate needs it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaim:melekcore-enginepriority: mediumscope:sweep

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions