Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Aug 2018 14:45:53 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r337258 - stable/10/sys/kern
Message-ID:  <201808031445.w73EjraV086933@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Fri Aug  3 14:45:53 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

Modified:
  stable/10/sys/kern/kern_thr.c
  stable/10/sys/kern/kern_thread.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_thr.c
==============================================================================
--- stable/10/sys/kern/kern_thr.c	Fri Aug  3 14:37:23 2018	(r337257)
+++ stable/10/sys/kern/kern_thr.c	Fri Aug  3 14:45:53 2018	(r337258)
@@ -362,6 +362,11 @@ kern_thr_exit(struct thread *td)
 	racct_sub(p, RACCT_NTHR, 1);
 	tdsigcleanup(td);
 	umtx_thread_exit(td);
+
+#ifdef AUDIT
+	AUDIT_SYSCALL_EXIT(0, td);
+#endif
+
 	PROC_SLOCK(p);
 	thread_stopped(p);
 	thread_exit();

Modified: stable/10/sys/kern/kern_thread.c
==============================================================================
--- stable/10/sys/kern/kern_thread.c	Fri Aug  3 14:37:23 2018	(r337257)
+++ stable/10/sys/kern/kern_thread.c	Fri Aug  3 14:45:53 2018	(r337258)
@@ -418,9 +418,6 @@ thread_exit(void)
 	SDT_PROBE0(proc, , , lwp__exit);
 	KASSERT(TAILQ_EMPTY(&td->td_sigqueue.sq_list), ("signal pending"));
 
-#ifdef AUDIT
-	AUDIT_SYSCALL_EXIT(0, td);
-#endif
 	/*
 	 * drop FPU & debug register state storage, or any other
 	 * architecture specific resources that



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808031445.w73EjraV086933>