[BUG] Closing the app terminal hard-freezes/reboots LineageOS 24 (6.6): AVC audit flood from permissive droidspacesd fills the 64-entry audit backlog
Environment
| item | value |
|---|---|
| device | OnePlus Ace 5 Pro (hummer, PKR110) |
| ROM | LineageOS 24.0-20261106-NIGHTLY-hummer (Android 16) |
| kernel | 6.6.144-4k-g6350e8af3f4c (stock LineageOS) |
| root | KernelSU (LKM, boot ramdisk patched) |
| Droidspaces | v7.2.0 (app + daemon + boot module) |
| container | Kali, DAEMON mode, NAT |
| sepolicy | stock from this repo's boot-module/sepolicy.rule |
Bug
Opening the container terminal in the app and then typing exit (or pressing the tab close ×) hard-freezes the whole phone, then the PMIC watchdog resets it (PS_HOLD / HARD_RESET). No kernel panic, no pstore on this ROM.
It is 100% reproducible, and only through the app terminal. Entering the same container over an adb pty does not crash.
What the kernel trace shows
ftrace kprobes around the app-side shutdown:
zsh / su / droidspaces:
do_exit -> exit_files -> disassociate_ctty -> exit_task_namespaces
-> release_task -> dnotify (all returned)
su-8767 (client side):
mntput / fput / security_file_free (all returned)
audit_start -> returned
audit_end
audit_start -> returned
audit_end
... repeated ...
audit_start <-- trace cut here, whole kernel silent
At the same moment kmsg ends with:
avc: denied { write } for comm="zsh" name="root" ...
avc: denied { add_name } ... .zsh_history.LOCK
avc: denied { create } ... .zsh_history
audit: audit_lost=8995 audit_rate_limit=5 audit_backlog_limit=64
The last 20 ms of kernel activity are all audit records from the exiting client shell.
Root cause
audit_log_start() (kernel/audit.c) sleeps when the audit queue is over the limit:
while (audit_backlog_limit &&
(skb_queue_len(&audit_queue) > audit_backlog_limit)) {
wake_up_interruptible(&kauditd_wait);
if (gfpflags_allow_blocking(gfp_mask) && (stime > 0)) {
set_current_state(TASK_UNINTERRUPTIBLE);
stime = schedule_timeout(rtime);
...
}
}
audit_backlog_limit on this ROM is 64. The container's droidspacesd domain is declared permissive droidspacesd, and the policy is missing several allows, so every container file operation emits an avc: denied record. Under that flood the queue never drains, tasks sleep in audit_log_start(), and the whole system stops until the watchdog bites.
This also explains why the adb pty path does not crash: it has a much smaller audit burst (no KernelSU su + app-side sh chain), and the phDroid LKM teardown itself is clean.
Evidence of the policy gap
Examples of denials that the shipped sepolicy.rule does not allow (all currently permissive):
droidspacesd -> droidspacesd_exec : file { read open getattr map execute execute_no_trans }
droidspacesd -> system_data_file : dir { write add_name create remove_name unlink setattr search }
droidspacesd -> system_data_file : file { create write setattr rename unlink append }
droidspacesd -> tmpfs : file/dir/lnk_file/sock_file { create write unlink rename ... }
droidspacesd -> devpts : chr_file { open read write ioctl lock }
droidspacesd -> cgroup_v2 : dir/file { create write read ... }
droidspacesd -> proc / sysfs : file { read open getattr }
...
There are ~150 unique droidspacesd denial signatures. Note that droidspacesd_exec is allowed for init/ksu/magisk/su as source, but there is no allow droidspacesd droidspacesd_exec ... rule, so the daemon reading/exec'ing its own binary is denied and audited.
This matches the analysis in #90 (Context u:object_r:droidspacesd_exec:s0 is not valid, Could not set context for rootfs.img: Permission denied), but here it ends in a hard freeze instead of only failed starts.
Suggested fixes
Any of these would remove the flood:
- Add
dontauditrules for the expected denials (especiallydroidspacesd_exec,system_data_file,tmpfs,devpts,cgroup_v2,proc,sysfs), or - Add the missing
allowrules so the operations are not denied at all, or - Relabel the container rootfs / daemon binary to a type the domain fully owns (see #90), so no denials are generated, or
- Make the daemon not run the whole container in a permissive, unaudited domain.
Raising audit_backlog_limit alone is not enough; it only delays the fill.
I can attach the full ftrace (kprobe) log, kmsg, and the complete list of denial signatures. The device owner is available to test a fix; no phone-side changes are wanted.
Note: this was found while debugging a Droidspaces-compatible LKM (phDroid); the LKM's namespace teardown is fully clean in the traces.
Proposed fix (policy-only, no runtime changes): #391
It appends dontaudit rules for the observed denials of the permissive droidspacesd domain to boot-module/sepolicy.rule (43 target-type/class groups, permissions merged from the crash logs). Only the audit records are dropped; permission decisions and other domains are unchanged.
Happy to trim the list or switch to the missing allow rules if you prefer.
Correction to our earlier diagnosis: this does not look like an audit-backlog hang.
We installed the dontaudit boot-module (#391) and the device still hard-resets when the App terminal is closed. The ftrace capture shows the container namespaces are fully released, then the hang happens in __tty_hangup() -> tty_signal_session_leader() (read side of tasklist_lock + sighand->siglock), with the next release_task() queued as a writer. That is a tasklist_lock writer-pending deadlock, not audit_log_start().
The audit flood is real (audit_lost=6779, audit_backlog_limit=64) but it is a symptom of the permissive droidspacesd domain, not the reset trigger. Keeping #391 open is still useful as a noise reduction, but it is not the fix for this crash.
The remaining suspect is the fake PID namespace / session pid, which lives in the LKM, not in the app.
Closing this, since it isn't a Droidspaces bug. The freeze happens in the kernel, on a setup where the PID and IPC namespaces are emulated by an out-of-tree LKM instead of being compiled in. The LKM's maintainer has also said it's an LKM problem and is working on a fix: https://github.com/Dere3046/_patchHarmony/issues/15
We only support kernels built with the required configuration. If you can reproduce this on a kernel with CONFIG_PID_NS and CONFIG_IPC_NS compiled in and no namespace LKM loaded, let us know and we'll reopen it.
The audit log spam itself is handled by https://github.com/ravindu644/Droidspaces-OSS/commit/703ded234df74985a952835c00972fb80e8f98d6