Summary: | "exa-0.8.0" panics the kernel while auditd(8) is running and audit_mask is set as "pc" | ||
---|---|---|---|
Product: | Base System | Reporter: | Aniket Pandey <aniketp> |
Component: | kern | Assignee: | Alan Somers <asomers> |
Status: | Closed FIXED | ||
Severity: | Affects Only Me | CC: | aniketp, asomers, gnn, rwatson |
Priority: | --- | Flags: | asomers:
mfc-stable11+
asomers: mfc-stable10+ |
Version: | CURRENT | ||
Hardware: | amd64 | ||
OS: | Any |
Description
Aniket Pandey
2018-05-23 19:28:19 UTC
What version of FreeBSD were you using? If CURRENT, what svn rev? Please supply the output of "uname -a" > uname -a
> FreeBSD bsdtest 12.0-CURRENT FreeBSD 12.0-CURRENT #1: Mon May 21 20:10:48 IST 2018 root@bsdtest:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
I reproduced this bug in a different way. Simply doing a kernel build while "pc" is in the audit mask and auditd is running will do it. I also found the root cause: 1) kern_thr_exit locks the process's spin lock with PROC_SLOCK(p) 2) thread_exit() calls AUDIT_SYSCALL_EXIT while the spin lock is still held 3) a few stack frames later, au_event_class tries to lock a rwlock with EVCLASS_RLOCK. However, witness forbids grabbing an rwlock while holding a spin lock. The likeliest solution is to fix thread_exit so that AUDIT_SYSCALL_EXIT isn't called with the spin lock held. A commit references this bug: Author: asomers Date: Wed Jul 11 19:38:42 UTC 2018 New revision: 336205 URL: https://svnweb.freebsd.org/changeset/base/336205 Log: Don't acquire evclass_lock with a spinlock held When the "pc" audit class is enabled and auditd is running, witness will panic during thread exit because au_event_class tries to lock an rwlock while holding a spinlock acquired upstack by thread_exit. To fix this, move AUDIT_SYSCALL_EXIT futher upstack, before the spinlock is acquired. Of thread_exit's 16 callers, it's only necessary to call AUDIT_SYSCALL_EXIT from two, exit1 (for exiting processes) and kern_thr_exit (for exiting threads). The other callers are all kernel threads, which needen't call AUDIT_SYSCALL_EXIT because since they can't make syscalls there will be nothing to audit. And exit1 already does call AUDIT_SYSCALL_EXIT, making the second call in thread_exit redundant for that case. PR: 228444 Reported by: aniketp Reviewed by: aniketp, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16210 Changes: head/sys/kern/kern_thr.c head/sys/kern/kern_thread.c A commit references this bug: Author: asomers Date: Fri Aug 3 14:05:23 UTC 2018 New revision: 337242 URL: https://svnweb.freebsd.org/changeset/base/337242 Log: MFC r336205: Don't acquire evclass_lock with a spinlock held When the "pc" audit class is enabled and auditd is running, witness will panic during thread exit because au_event_class tries to lock an rwlock while holding a spinlock acquired upstack by thread_exit. To fix this, move AUDIT_SYSCALL_EXIT futher upstack, before the spinlock is acquired. Of thread_exit's 16 callers, it's only necessary to call AUDIT_SYSCALL_EXIT from two, exit1 (for exiting processes) and kern_thr_exit (for exiting threads). The other callers are all kernel threads, which needen't call AUDIT_SYSCALL_EXIT because since they can't make syscalls there will be nothing to audit. And exit1 already does call AUDIT_SYSCALL_EXIT, making the second call in thread_exit redundant for that case. PR: 228444 Reported by: aniketp Reviewed by: aniketp, kib Differential Revision: https://reviews.freebsd.org/D16210 Changes: _U stable/11/ stable/11/sys/kern/kern_thr.c stable/11/sys/kern/kern_thread.c A commit references this bug: Author: asomers Date: Fri Aug 3 14:45:54 UTC 2018 New revision: 337258 URL: https://svnweb.freebsd.org/changeset/base/337258 Log: MFC r336205: Don't acquire evclass_lock with a spinlock held When the "pc" audit class is enabled and auditd is running, witness will panic during thread exit because au_event_class tries to lock an rwlock while holding a spinlock acquired upstack by thread_exit. To fix this, move AUDIT_SYSCALL_EXIT futher upstack, before the spinlock is acquired. Of thread_exit's 16 callers, it's only necessary to call AUDIT_SYSCALL_EXIT from two, exit1 (for exiting processes) and kern_thr_exit (for exiting threads). The other callers are all kernel threads, which needen't call AUDIT_SYSCALL_EXIT because since they can't make syscalls there will be nothing to audit. And exit1 already does call AUDIT_SYSCALL_EXIT, making the second call in thread_exit redundant for that case. PR: 228444 Reported by: aniketp Reviewed by: aniketp, kib Differential Revision: https://reviews.freebsd.org/D16210 Changes: _U stable/10/ stable/10/sys/kern/kern_thr.c stable/10/sys/kern/kern_thread.c |