NetBSD Problem Report #21628

Received: (qmail 3419 invoked by uid 605); 20 May 2003 14:12:19 -0000
Message-Id: <200305201412.h4KECGRv005444@fred.tools.de>
Date: Tue, 20 May 2003 16:12:16 +0200 (MEST)
From: Wolfgang Solfrank <ws@fred.tools.de>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: ws@fred.tools.de
To: gnats-bugs@gnats.netbsd.org
Subject: Locking bug in linux_sys_fcntl
X-Send-Pr-Version: 3.95

>Number:         21628
>Category:       kern
>Synopsis:       Locking bug in linux_sys_fcntl
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jdolecek
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 20 14:13:00 +0000 2003
>Closed-Date:    Tue Jul 01 09:23:46 +0000 2003
>Last-Modified:  Tue Jul 01 09:23:46 +0000 2003
>Originator:     Wolfgang Solfrank
>Release:        NetBSD 1.6T (2003/05/19)
>Organization:
TooLs GmbH
>Environment:
System: NetBSD fred.tools.de 1.6T NetBSD 1.6T (fred) #27: Mon May 19 17:34:12 MEST 2003 ws@fred.tools.de:/src/obj/sys/arch/i386/compile/fred i386
Architecture: i386
Machine: i386
>Description:

There is a comment in linux_sys_fcntl that states that it's not
neccessary to call FILE_USE here.

Since FILE_USE has the side effect (as documented at the definition
of FILE_USE) of unlocking the file locked by the preceding call
to fd_getfile, this is not correct.

While this works in the common case of a simgle processor kernel
without LOCKDEBUG, it hangs on multiprocessor machines.

The patch below is somewhat non-optimal, as it includes repeated
locking of the file structure.  Maybe there should be a new
macro in sys/file.h for just doing the unlock on a file.

>How-To-Repeat:

Try to use javac from sun-jdk13.

>Fix:

Index: linux_file.c
===================================================================
RCS file: /cvsroot/src/sys/compat/linux/common/linux_file.c,v
retrieving revision 1.58
diff -c -r1.58 linux_file.c
*** linux_file.c	2003/03/19 11:36:35	1.58
--- linux_file.c	2003/05/20 13:58:49
***************
*** 427,433 ****
  		fdp = p->p_fd;
  		if ((fp = fd_getfile(fdp, fd)) == NULL)
  			return EBADF;
! 		/* FILE_USE() not needed here */
  		if (fp->f_type != DTYPE_VNODE) {
  	    not_tty:
  			/* Not a tty, proceed with common fcntl() */
--- 427,434 ----
  		fdp = p->p_fd;
  		if ((fp = fd_getfile(fdp, fd)) == NULL)
  			return EBADF;
! 		FILE_USE(fp);
! 		FILE_UNUSE(fp, p);
  		if (fp->f_type != DTYPE_VNODE) {
  	    not_tty:
  			/* Not a tty, proceed with common fcntl() */
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->jdolecek 
Responsible-Changed-By: jdolecek 
Responsible-Changed-When: Fri May 23 20:26:08 UTC 2003 
Responsible-Changed-Why:  
I''ll fix this. 
State-Changed-From-To: open->feedback 
State-Changed-By: jdolecek 
State-Changed-When: Sun Jun 29 14:52:22 UTC 2003 
State-Changed-Why:  
I committed a fix for this problem in rev 1.60 of  
sys/compat/linux/common/linux_file.c 
Can you update your kernel sources and confirm whether or not the 
problem is fixed? 
Thanks. 

From: Jaromir Dolecek <jdolecek@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/21628 CVS commit: src/sys/compat/linux/common
Date: Sun, 29 Jun 2003 14:51:29 +0000 (UTC)

 Module Name:	src
 Committed By:	jdolecek
 Date:		Sun Jun 29 14:51:29 UTC 2003

 Modified Files:
 	src/sys/compat/linux/common: linux_file.c

 Log Message:
 properly FILE_USE/FILE_UNUSE descriptor in linux_sys_fcntl()
 adresses PR kern/21628 by Wolfgang Solfrank


 To generate a diff of this commit:
 cvs rdiff -r1.59 -r1.60 src/sys/compat/linux/common/linux_file.c

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

State-Changed-From-To: feedback->closed 
State-Changed-By: jdolecek 
State-Changed-When: Tue Jul 1 09:23:15 UTC 2003 
State-Changed-Why:  
Confirmed okay by the submitter. 
Thanks for report. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.