Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 May 2019 13:03:55 +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: r347690 - head/sys/kern
Message-ID:  <201905161303.x4GD3tT2061069@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu May 16 13:03:54 2019
New Revision: 347690
URL: https://svnweb.freebsd.org/changeset/base/347690

Log:
  imgact_elf.c: Add comment explaining the malloc/VOP_UNLOCK() dance
  from r347148.
  
  Requested by:	alc
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 days

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==============================================================================
--- head/sys/kern/imgact_elf.c	Thu May 16 13:00:35 2019	(r347689)
+++ head/sys/kern/imgact_elf.c	Thu May 16 13:03:54 2019	(r347690)
@@ -935,12 +935,22 @@ __elfN(get_interp)(struct image_params *imgp, const El
 	interp_name_len = phdr->p_filesz;
 	if (phdr->p_offset > PAGE_SIZE ||
 	    interp_name_len > PAGE_SIZE - phdr->p_offset) {
+		/*
+		 * The vnode lock might be needed by pagedaemon to
+		 * clean pages owned by the vnode.  Do not allow sleep
+		 * waiting for memory with the vnode locked, instead
+		 * try non-sleepable allocation first, and if it
+		 * fails, go to the slow path were we drop the lock
+		 * and do M_WAITOK.  Text reference prevents
+		 * modifications of the vnode content.
+		 */
 		interp = malloc(interp_name_len + 1, M_TEMP, M_NOWAIT);
 		if (interp == NULL) {
 			VOP_UNLOCK(imgp->vp, 0);
 			interp = malloc(interp_name_len + 1, M_TEMP, M_WAITOK);
 			vn_lock(imgp->vp, LK_SHARED | LK_RETRY);
 		}
+
 		error = vn_rdwr(UIO_READ, imgp->vp, interp,
 		    interp_name_len, phdr->p_offset,
 		    UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred,



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