Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Remove a superfluous VOP_GETATTR() from elf_load_in...



details:   https://anonhg.NetBSD.org/src/rev/0dc1610b52be
branches:  trunk
changeset: 379192:0dc1610b52be
user:      hannken <hannken%NetBSD.org@localhost>
date:      Tue May 18 08:59:44 2021 +0000

description:
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.

diffstat:

 sys/kern/exec_elf.c |  12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diffs (47 lines):

diff -r 8bc97fd11638 -r 0dc1610b52be sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c       Tue May 18 07:17:09 2021 +0000
+++ b/sys/kern/exec_elf.c       Tue May 18 08:59:44 2021 +0000
@@ -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



Home | Main Index | Thread Index | Old Index