From nobody@FreeBSD.org  Mon Apr 29 01:19:47 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id AA6B937B404
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Apr 2002 01:19:46 -0700 (PDT)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g3T8JkE95791;
	Mon, 29 Apr 2002 01:19:46 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200204290819.g3T8JkE95791@freefall.freebsd.org>
Date: Mon, 29 Apr 2002 01:19:46 -0700 (PDT)
From: Peter Edwards <pmedwards@eircom.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: vnode flags appear to be changed in non-safe manner in kern/elf_imgact.c
X-Send-Pr-Version: www-1.0

>Number:         37555
>Category:       kern
>Synopsis:       [kernel] [patch] vnode flags appear to be changed in non-safe manner in kern/elf_imgact.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 29 01:20:01 PDT 2002
>Closed-Date:    
>Last-Modified:  Wed Oct 26 00:00:27 GMT 2005
>Originator:     Peter Edwards
>Release:        4-STABLE
>Organization:
>Environment:
FreeBSD rocklobster 4.5-STABLE FreeBSD 4.5-STABLE #30: Mon Apr 29 08:00:03 IST 2002     petere@rocklobster:/pub/FreeBSD/work/src/sys/compile/ROCKLOBSTER  i386

>Description:
The "VTEXT" flag added by imgact_elf.c is added once while holding the
v_interlock simple lock on the vnode in question, and once without.

As well as being inconsistent, I assume there's a possible race here
for 5.x, which also lacks the simple_lock() around the vnode for one
case
>How-To-Repeat:

>Fix:
--- imgact_elf.c        16 Dec 2001 18:26:16 -0000      1.73.2.9
+++ imgact_elf.c        29 Apr 2002 08:17:42 -0000
@@ -376,8 +376,11 @@
         * Also make certain that the interpreter stays the same, so set
         * its VTEXT flag, too.
         */
-       if (error == 0)
+       if (error == 0) {
+               simple_lock(&nd->ni_vp->v_interlock);
                nd->ni_vp->v_flag |= VTEXT;
+               simple_unlock(&nd->ni_vp->v_interlock);
+       }
        VOP_UNLOCK(nd->ni_vp, 0, p);
        if (error)
                 goto fail;


>Release-Note:
>Audit-Trail:

From: Peter Edwards <pmedwards@eircom.net>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: kern/37555: vnode flags appear to be changed in non-safe manner in kern/elf_imgact.c
Date: Mon, 29 Apr 2002 01:19:46 -0700 (PDT)

 >Number:         37555
 >Category:       kern
 >Synopsis:       vnode flags appear to be changed in non-safe manner in kern/elf_imgact.c
 >Confidential:   no
 >Severity:       non-critical
 >Priority:       low
 >Responsible:    freebsd-bugs
 >State:          open
 >Quarter:        
 >Keywords:       
 >Date-Required:
 >Class:          sw-bug
 >Submitter-Id:   current-users
 >Arrival-Date:   Mon Apr 29 01:20:01 PDT 2002
 >Closed-Date:
 >Last-Modified:
 >Originator:     Peter Edwards
 >Release:        4-STABLE
 >Organization:
 >Environment:
 FreeBSD rocklobster 4.5-STABLE FreeBSD 4.5-STABLE #30: Mon Apr 29 08:00:03 IST 2002     petere@rocklobster:/pub/FreeBSD/work/src/sys/compile/ROCKLOBSTER  i386
 
 >Description:
 The "VTEXT" flag added by imgact_elf.c is added once while holding the
 v_interlock simple lock on the vnode in question, and once without.
 
 As well as being inconsistent, I assume there's a possible race here
 for 5.x, which also lacks the simple_lock() around the vnode for one
 case
 >How-To-Repeat:
 
 >Fix:
 --- imgact_elf.c        16 Dec 2001 18:26:16 -0000      1.73.2.9
 +++ imgact_elf.c        29 Apr 2002 08:17:42 -0000
 @@ -376,8 +376,11 @@
          * Also make certain that the interpreter stays the same, so set
          * its VTEXT flag, too.
          */
 -       if (error == 0)
 +       if (error == 0) {
 +               simple_lock(&nd->ni_vp->v_interlock);
                 nd->ni_vp->v_flag |= VTEXT;
 +               simple_unlock(&nd->ni_vp->v_interlock);
 +       }
         VOP_UNLOCK(nd->ni_vp, 0, p);
         if (error)
                  goto fail;
 
 
 >Release-Note:
 >Audit-Trail:
 >Unformatted:
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-bugs" in the body of the message
 
>Unformatted:
