β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-3014

hammer_ip_sync_record_cursor() error path frees the bulk record's data reservation on retryable EDEADLK and ignores hammer_blockmap_finalize() failure β€” double-finalize / blockmap accounting corruption on the flush retry

Field Value
ID DF-3014
Status new
Severity Low
CVSS 3.1 CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:H/A:L
CWE CWE-672
File sys/vfs/hammer/hammer_object.c
Lines 1256, 1283, 1331-1335
Area vfs/hammer
Confidence speculative
Discovered 2026-09-02
Pass 2 (GLM 5.3 second pass)
Bucket base:vfs
Reported pending
Known CVE none
CVE match novel

Summary

For HAMMER_MEM_RECORD_DATA records the data_offset is a blockmap reservation, finalized at :1256 and consumed by the btree insert at :1283. (a) hammer_blockmap_finalize()'s return value is never checked before the insert β€” a failed finalize silently proceeds to insert a record referencing unfinalized space. (b) If hammer_btree_insert() returns EDEADLK (retryable β€” the caller loop in hammer_inode.c:1331-1345 re-runs sync_record_cursor for the same record), the else-branch at :1331-1335 calls hammer_blockmap_free(data_offset, data_len) on the reservation, and the retry then re-runs blockmap_finalize() on the same resv/data_offset β€” a free-then-finalize sequence that corrupts layer2 bytes_free/zone accounting (free() may even reset the bigblock while the resv is still live in rb_resv_root, inviting double allocation of the same space). Filesystem integrity impact, race-gated (insert-time EDEADLK or finalize failure while syncing a direct-write record), no kernel memory-safety effect. Not stageable deterministically from userspace. Fix: skip hammer_blockmap_free() when error == EDEADLK (the reservation remains valid for the retry) + check finalize's error.

Timeline

  • 2026-09-02 Discovered during pass-2 audit of hammer_object.c (GLM 5.3). DF-3004's fix NOT landed β€” :855 still unconditional (belongs here per DF-3004; not re-reported).

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-3014 Β· 8 files
FileTypeDescriptionSize
README.md β€” 343 B ↓ raw
VERDICT.md β€” 1.0 KB ↓ raw
df3013stress.c β€” 1.4 KB view raw
env.txt β€” 248 B view raw
fix.diff β€” 155 B view raw
manifest.json β€” 586 B view raw
run.log β€” 120 B view raw
verdict.json β€” 1.4 KB view raw

DF-3014 - hammer_ip_sync_record_cursor frees bulk reservation on retryable EDEADLK; finalize error ignored

Severity Low | verdict: not_reproduced | impact: none

Reproduce

Sources in this directory; build with cc -O2 -o <bin> <src> -pthread on the guest.

See VERDICT.md for the full narrative and run.log for the decisive output.

VERDICT.md
↓ download raw

DF-3014 verification

Kernel: DragonFly dfbsd 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64

Same 90-second stress rig as DF-3013 (writers + readdirs + reblock/prune). The double-finalize/blockmap accounting corruption path requires a btree EDEADLK precisely inside hammer_ip_sync_record_cursor for a HAMMER_MEM_RECORD_DATA record; not crossed under load. Code-verified race remains (hammer_object.c:1331-1335 blockmap_free on EDEADLK retry; finalize return unchecked at :1256).

Kernel references

Fix

See fix.diff.

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

not_testable
↓ fix.diffper-fix-DF-3014

Confirmed kernel references

Detail

Evidence (decisive lines)

VERDICT.md + run.log + sources

PoC changes

adjusted from finding sketch to guest syscall/layout reality

Verified recommended fix

diff: skip hammer_blockmap_free when error==EDEADLK (the caller re-runs sync_record_cursor) and check hammer_blockmap_finalize return before the insert.

Verdict

Same 90-second stress rig as DF-3013 (writers + readdirs + reblock/prune). The double-finalize/blockmap accounting corruption path requires a btree EDEADLK precisely inside hammer_ip_sync_record_cursor for a HAMMER_MEM_RECORD_DATA record; not crossed under load. Code-verified race remains (hammer_object.c:1331-1335 blockmap_free on EDEADLK retry; finalize return unchecked at :1256).