Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Feb 2015 13:07:32 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279237 - head/sys/kern
Message-ID:  <201502241307.t1OD7WhZ002296@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Feb 24 13:07:31 2015
New Revision: 279237
URL: https://svnweb.freebsd.org/changeset/base/279237

Log:
  Keep a reference on the coredump vnode for vn_fullpath() call.  Do it
  by moving vn_close() after the point where notification is sent.
  
  Reported by:	sbruno
  Tested by:	pho, sbruno
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/kern_sig.c
==============================================================================
--- head/sys/kern/kern_sig.c	Tue Feb 24 12:57:03 2015	(r279236)
+++ head/sys/kern/kern_sig.c	Tue Feb 24 13:07:31 2015	(r279237)
@@ -3310,7 +3310,7 @@ coredump(struct thread *td)
 	    vattr.va_nlink != 1 || (vp->v_vflag & VV_SYSTEM) != 0) {
 		VOP_UNLOCK(vp, 0);
 		error = EFAULT;
-		goto close;
+		goto out;
 	}
 
 	VOP_UNLOCK(vp, 0);
@@ -3347,17 +3347,12 @@ coredump(struct thread *td)
 		VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK);
 	}
 	vn_rangelock_unlock(vp, rl_cookie);
-close:
-	error1 = vn_close(vp, FWRITE, cred, td);
-	if (error == 0)
-		error = error1;
-	else
-		goto out;
+
 	/*
 	 * Notify the userland helper that a process triggered a core dump.
 	 * This allows the helper to run an automated debugging session.
 	 */
-	if (coredump_devctl == 0)
+	if (error != 0 || coredump_devctl == 0)
 		goto out;
 	len = MAXPATHLEN * 2 + sizeof(comm_name) - 1 +
 	    sizeof(' ') + sizeof(core_name) - 1;
@@ -3377,6 +3372,9 @@ close:
 	strlcat(data, fullpath, len);
 	devctl_notify("kernel", "signal", "coredump", data);
 out:
+	error1 = vn_close(vp, FWRITE, cred, td);
+	if (error == 0)
+		error = error1;
 #ifdef AUDIT
 	audit_proc_coredump(td, name, error);
 #endif



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