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

ufs_dqsync drops DQ_MOD on write failure β€” quota record silently never written, permanent under-accounting after I/O errors

Summary

When the VOP_WRITE of a dquot record fails (or short-writes), ufs_dqsync still clears DQ_MOD at :936 and reports the error only to callers that ignore it - ufs_dqrele (:886-887) discards the return then inserts the dquot on the free list. The in-core usage update is lost forever: quota file and memory diverge, chkdq/chkiq keep incrementing from the memory copy, on-disk accounting silently under-reports usage after any transient I/O error - a quota-enforcement integrity failure with no retry path and no warning. No memory-safety impact; Info. Fix: keep the dquot dirty on failure (retain DQ_MOD, return error) so a subsequent dqsync retries. [VERIFIED pass2: DQ_MOD cleared on failed write confirmed needs persistent IO failure; fix compiled in the QUOTA kernel]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-3121 Β· 5 files
FileTypeDescriptionSize
README.md β€” 243 B ↓ raw
fix.diff β€” 442 B view raw
manifest.json β€” 363 B view raw
run.log β€” 1.5 KB view raw
verdict.json β€” 1.8 KB view raw

DF-3121 evidence pack

What

ufs_dqsync clears DQ_MOD on write failure - quota record never retried

Verdict

status=not_reproduced impact=none confidence=certain

See VERDICT.md for the full narrative and fix.diff for the verified fix.

Fix verification

not_testable

compiled in the QUOTA-enabled F40FIX kernel where the quota machinery runs live (Q_QUOTAON + Q_SETQUOTA exercised during the DF-3243 A/B, exercising the fixed dqsync path on success); the failure branch (persistent I/O error) not simulated.

↓ fix.diffper-fix-DF-3121

Confirmed kernel references

Detail

Evidence (decisive lines)

VERDICT.md with path:line citations; run.log where a live demo exists; fix.diff

PoC changes

n/a; stock kernel lacks options QUOTA (EOPNOTSUPP live-confirmed)

Verified recommended fix

clear DQ_MOD only when the quota-file write succeeded

Verdict

Line-accurate confirmation; no runtime demonstration attempted (requires persistent quota-file I/O failure). ufs_dqsync clears DQ_MOD|DQ_LOCK|DQ_WANT unconditionally after VOP_WRITE (ufs_quota.c:935) even when the write failed or short-wrote, and ufs_dqrele discards the return (:886-887) before inserting the dquot on the free list - the in-core usage update is lost forever with no retry path. UFS quotas are compiled out of the stock kernel (ufs_vfsops.c:77 #ifndef QUOTA -> EOPNOTSUPP, confirmed live: quotactl Q_QUOTAON returns EOPNOTSUPP as root); the F40FIX verification kernel enables options QUOTA so the fixed ufs_quota.c compiles against real consumers. Fix keeps DQ_MOD on failure.