Module Name:    src
Committed By:   hannken
Date:           Tue May 18 08:59:44 UTC 2021

Modified Files:
        src/sys/kern: exec_elf.c

Log Message:
Remove a superfluous VOP_GETATTR() from elf_load_interp() and replace
the LK_EXCLUSIVE lock with a LK_SHARED lock.

The attributes requested were not used since Rev 1.25 of exec_elf32.c
from 1997/05/08 when mycroft GCd the va_mode check.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/kern/exec_elf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.101 src/sys/kern/exec_elf.c:1.102
--- src/sys/kern/exec_elf.c:1.101	Sun Jan 12 18:30:58 2020
+++ src/sys/kern/exec_elf.c	Tue May 18 08:59:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec_elf.c,v 1.101 2020/01/12 18:30:58 ad Exp $	*/
+/*	$NetBSD: exec_elf.c,v 1.102 2021/05/18 08:59:44 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1994, 2000, 2005, 2015, 2020 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.101 2020/01/12 18:30:58 ad Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.102 2021/05/18 08:59:44 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -421,7 +421,6 @@ elf_load_interp(struct lwp *l, struct ex
 {
 	int error, i;
 	struct vnode *vp;
-	struct vattr attr;
 	Elf_Ehdr eh;
 	Elf_Phdr *ph = NULL;
 	const Elf_Phdr *base_ph;
@@ -456,7 +455,7 @@ elf_load_interp(struct lwp *l, struct ex
 	}
 	/* We'll tidy this ourselves - otherwise we have locking issues */
 	epp->ep_interp = NULL;
-	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+	vn_lock(vp, LK_SHARED | LK_RETRY);
 
 	/*
 	 * Similarly, if it's not marked as executable, or it's not a regular
@@ -469,11 +468,6 @@ elf_load_interp(struct lwp *l, struct ex
 	if ((error = VOP_ACCESS(vp, VEXEC, l->l_cred)) != 0)
 		goto bad;
 
-	/* get attributes */
-	/* XXX VOP_GETATTR() is the only thing that needs LK_EXCLUSIVE ^ */
-	if ((error = VOP_GETATTR(vp, &attr, l->l_cred)) != 0)
-		goto bad;
-
 	/*
 	 * Check mount point.  Though we're not trying to exec this binary,
 	 * we will be executing code from it, so if the mount point

Reply via email to