sys/libkern/flsll.c is dead, unlistable, and shadowed code (find-LAST-set, long long)
Summary
Shadowed by the cpufunc.h delegating inline (flsl((long)mask)) used by tmpfs/drm. In-kernel compile fails redefinition. Three-axis differential (inline + clzll ref + flsl twin) 0/58.45M. Note: the inline's (long) delegation would truncate on ILP32 where this file's (unsigned long long) loop would not - a portability trap the dead file papered over, moot on x86_64-only. gate-or-delete fix validated.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-5717 Β· 17 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | β | 2.2 KB | β raw | |
| VERDICT.md | β | 3.7 KB | β raw | |
| verdict.json | β | 5.3 KB | view raw | |
| manifest.json | β | 1.2 KB | view raw | |
| p2_harness.c | β | 5.7 KB | view raw | |
| build.sh | β | 127 B | view raw | |
| run.sh | β | 90 B | view raw | |
| k_flsll.c | β | 1.8 KB | view raw | |
| f_flsll_gated.c | β | 1.9 KB | view raw | |
| build.log | β | 1.8 KB | view raw | |
| run.log | β | 463 B | view raw | |
| dead_compile_flsll.log | β | 652 B | view raw | |
| fix_compile_flsll.log | β | 278 B | view raw | |
| fix_build.log | β | 904 B | view raw | |
| fix_run.log | β | 458 B | view raw | |
| env.txt | β | 212 B | view raw | |
| fix.diff | β | 251 B | view raw |
DF-5717 β sys/libkern/flsll.c dead-file status + latent-correctness proof
Pass-2 (GLM 5.3) verification of the flsll (find-LAST-set, long long)
member of the ffs/fls family (family context established by DF-5714 for
ffs.c; rig pattern identical).
What was machine-proven on the DragonFly guest
- Dead file:
libkern/flsll.chas no entry insys/conf/files(libkern block 2195β2237;grep -c= 0 on host and guest). Every kernel TU getsflsllasstatic __inlinefromsys/cpu/x86_64/include/cpufunc.h:298-304(HAVE_INLINE_FLSLL, delegating toflsl((long)mask)). - Cannot compile in-kernel as committed:
#include <sys/libkern.h>(flsll.c:32) pullslibkern.h:51 β systm.h:50 β machine/cpufunc.h, and the out-of-line definition at flsll.c:37-47 collides with thestatic __inline flsll: gcc 8.3error: redefinition of 'flsll'(dead_compile_flsll.log, kernel-style-nostdinc -D_KERNELcompile). - Latent body is arithmetically perfect: verbatim body vs the live
cpufunc.h inline (verbatim copy), vs
64 - __builtin_clzll, and vs the verbatim kernelflsltwin: 58,454,211 structure-complete cases β 0 mismatches on all three axes (run.logT3). - Fix validated at compile level:
fix.diff=#if !defined(HAVE_INLINE_FLSLL)gate. Gated file compiles kernel-style and defines no globalflsllsymbol on x86_64. Deletion equally valid.
Reproduce
Copy this directory to the guest and, as root:
sh build.sh # identity pin (cksum), conf/files census, verbatim renamed
# compiles, kernel-style deadproof, fix validation
sh run.sh # differential harness (~3 s)
Expected decisive lines:
DEADPROOF-OK: flsll.c cannot compile in-kernel as committed: ... error: redefinition of 'flsll' T3 flsll: 58454211 cases, 0 mism vs live-inline, 0 mism vs clz-ref, 0 mism vs kernel-flsl-twin HARNESS-PASS: ... FIXCOMPILE-OK: gated flsll.c compiles kernel-style; global flsll symbols in object: 0
build.sh expects the guest sources at /usr/src/sys (override with
S=...). Host/guest source identity: flsll.c cksum 1445885582 1884.
VERDICT β DF-5717: sys/libkern/flsll.c dead-file status + latent-correctness proof
Status: reproduced (impact: none β dead code, Info-severity hygiene
finding). Confidence: certain. Attempts: 2. All claims machine-demonstrated
on the DragonFly guest (uname in env.txt; guest source cksum-identical to
the audit tree: flsll.c 1445885582 1884, ffsl.c 1444671719 1875,
flsl.c 2802750667 1878).
The claim, and how each part was proven
flsll.cis not compiled into any DragonFly kernel or module. -sys/conf/fileslibkern block (lines 2195β2237) has noflsll.centry (census inbuild.log:grep -c= 0, host and guest). - Every kernel TU getsflsllasstatic __inlinefromsys/cpu/x86_64/include/cpufunc.h:298-304(#define HAVE_INLINE_FLSLL, bodyreturn (flsl((long)mask))); the prototype insys/sys/libkern.h:114-115is gated by#ifndef HAVE_INLINE_FLSLL.- The file cannot compile in-kernel as committed.
flsll.c:32includes<sys/libkern.h>βlibkern.h:51 β systm.h:50 β machine/cpufunc.hbrings thestatic __inline flsllinto the TU, and the out-of-line definition (flsll.c:37-47) collides:flsll.c:38:1: error: redefinition of 'flsll'/cpufunc.h:301:1: note: previous definition(dead_compile_flsll.log, kernel-style-nostdinc -D_KERNELcompile persys/conf/kern.pre.mk:61). Re-adding the file toconf/fileswould break the x86_64 kernel build. - The latent body is arithmetically perfect β find-LAST-set semantics
on
long longmachine-checked three ways. Verbatim kernel body vs (a) the live cpufunc.h inline implementation (verbatim copy of :300-304, i.e.flsl((long)mask)with the bsrq-based flsl), (b) the64 - __builtin_clzllreference, and (c) the verbatim kernelflslbody itself (the twin check β on x86_64longandlong longare both 64-bit): 0 / 58,454,211 mismatches on all three axes (run.logT3). Domain is structure-complete for the fls family (0, ~0,1<<63, all 64 single bits, exhaustive low-22 and top-22 words, every MSB position Γ1024, 50M randoms). Note the dead body uses(unsigned long long)mask >> 1(flsll.c:45) while the live inline delegates through(long)β output-identical on every tested input, as expected on LP64. - Consumer census (why this is Info, not higher). Live consumers:
sys/vfs/tmpfs/tmpfs_vnops.c:1952(max(32, flsll(tmp->tm_pages_max * PAGE_SIZE) + 1)) andsys/dev/drm/include/linux/log2.h:133. Both resolve to the inline; none references the dead object. No memory operands β overflow/ guard-page classes vacuous. - Fix.
fix.diff:#if !defined(HAVE_INLINE_FLSLL)gate. Validated: gated file compiles kernel-style, 0 globalflsllsymbols in the object on x86_64 (build.log"FIXCOMPILE-OK",fix_run.log). Deletion equally valid; consistent with DF-5714's ffs.c fix.
Why no further escalation was pursued
Pure register function, no pointers, linked nowhere β no runtime kernel behavior to attack. The pass-2 deliverable is the dead-file status plus the machine-checked find-last-set correctness proof (precedent: DF-5714, DF-5700, same class).
Rig honesty notes
- Same rig as DF-5715/DF-5716 (shared
build.sh/run.sh/p2_harness.c); first-shot success, no intermediate failed artifacts. See DF-5715's VERDICT for the scratch-file note.
Fix status (batch validation)
Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.
Fix verification
fixedValidation is at the compile level, which is exactly the level where the defect manifests (the file is linked nowhere, so there is no runtime behavior to A/B and no kernel rebuild to do). Baseline reproduced: the committed flsll.c fails kernel-style compile with 'redefinition of flsll' against cpufunc.h:301's static __inline (DEADPROOF-OK, dead_compile_flsll.log). Patched (fix.diff = HAVE_INLINE_FLSLL gate around the body): compiles kernel-style with zero errors (fix_compile_flsll.log contains only the pre-existing harmless 'conflicting types for built-in log' warning from systm.h:216) and the nm census shows 0 global flsll symbols in the object β the body compiles away on x86_64 exactly as the live tree expects (FIXCOMPILE-OK, fix_run.log).
dead_compile_flsll.log (baseline failure: error: redefinition of 'flsll', previous definition at cpufunc.h:301); fix_compile_flsll.log (gated compile, error-free); fix_run.log (baseline symbol k_flsll present vs patched census 0); build.log sections '== dead-file proof' / '== fix validation'; fix.diff
Confirmed kernel references
- sys/libkern/flsll.c:32
- sys/libkern/flsll.c:37-47
- sys/cpu/x86_64/include/cpufunc.h:298-304
- sys/sys/libkern.h:114-115
- sys/sys/libkern.h:51
- sys/conf/files:2195-2237
- sys/conf/kern.pre.mk:61
- sys/vfs/tmpfs/tmpfs_vnops.c:1952
Detail
Evidence (decisive lines)
build.log sections '== conf/files census' (libkern/flsll.c in conf/files: 0) and '== dead-file proof' (DEADPROOF-OK: flsll.c ... error: redefinition of 'flsll'; cpufunc.h:301 previous definition) with full gcc output in dead_compile_flsll.log; run.log 'T3 flsll: 58454211 cases, 0 mism vs live-inline, 0 mism vs clz-ref, 0 mism vs kernel-flsl-twin' + HARNESS-PASS; 'FIXCOMPILE-OK: gated flsll.c compiles kernel-style; global flsll symbols in object: 0' (fix validation); env.txt pins guest cksums == audit tree (flsll.c 1445885582 1884).
PoC changes
No seed PoC existed (pass 1 filed nothing). Rig authored per the DF-5714 pattern (same shared rig as DF-5715/DF-5716); the flsll reference is the cpufunc.h:300-304 inline copied byte-faithfully, plus a third comparison axis against the verbatim kernel flsl body (the twin check) to cover the inline's (long) delegation vs the file's own (unsigned long long) loop. First-shot success.
Verified recommended fix
Adopt fix.diff (#if !defined(HAVE_INLINE_FLSLL) gate around the body), or simply delete sys/libkern/flsll.c β it is unreferenced by conf/files and cannot compile in-kernel as committed.
Verdict
sys/libkern/flsll.c is dead code with a latent build hazard, same class as DF-5714 (ffs.c): absent from sys/conf/files (libkern block 2195-2237; grep -c = 0 verified on host and guest), superseded on the only supported arch by the cpufunc.h:298-304 static __inline flsll (HAVE_INLINE_FLSLL, delegating to flsl((long)mask); the libkern.h:114-115 prototype is itself gated), and non-compilable in-kernel as committed: the #include
No comments yet.