Re: [EXTERNAL] Re: audit: io_uring openat triggers audit reference count underflow in worker thread
From: Dan Clash
Date: Sun Oct 08 2023 - 22:38:58 EST
I retested with the following change as a sanity check:
- BUG_ON(name->refcnt <= 0);
+ BUG_ON(atomic_read(&name->refcnt) <= 0);
checkpatch.pl suggests using WARN_ON_ONCE rather than BUG.
devvm ~ $ ~/linux/scripts/checkpatch.pl --patch ~/io_uring_audit_hang_atomic.patch
WARNING: Do not crash the kernel unless it is absolutely unavoidable
--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants
#28: FILE: fs/namei.c:262:
+ BUG_ON(atomic_read(&name->refcnt) <= 0);
...
refcount_t uses WARN_ON_ONCE.
I can think of three choices:
1. Use atomic_t and remove the BUG line.
2. Use refcount_t and remove the BUG line.
3. Use atomic_t and partially implement the warn behavior of refcount_t.
Choice 1 and 2 seem better than choice 3.