Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 May 2019 09:24:52 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r347970 - stable/12/sys/kern
Message-ID:  <201905190924.x4J9OqQp041748@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sun May 19 09:24:51 2019
New Revision: 347970
URL: https://svnweb.freebsd.org/changeset/base/347970

Log:
  MFC r347690, r347946:
  imgact_elf.c: Add comment explaining the malloc/VOP_UNLOCK() dance
  from r347148.

Modified:
  stable/12/sys/kern/imgact_elf.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/imgact_elf.c
==============================================================================
--- stable/12/sys/kern/imgact_elf.c	Sun May 19 09:23:20 2019	(r347969)
+++ stable/12/sys/kern/imgact_elf.c	Sun May 19 09:24:51 2019	(r347970)
@@ -958,12 +958,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 the 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.  A text reference prevents
+		 * modifications to 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_EXCLUSIVE | 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?201905190924.x4J9OqQp041748>