NetBSD Problem Report #41006

From njoly@lanfeust.sis.pasteur.fr  Fri Mar 13 16:22:58 2009
Return-Path: <njoly@lanfeust.sis.pasteur.fr>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id E39FD63BE42
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 13 Mar 2009 16:22:58 +0000 (UTC)
Message-Id: <20090313162255.DA408DC9B9@lanfeust.sis.pasteur.fr>
Date: Fri, 13 Mar 2009 17:22:55 +0100 (CET)
From: njoly@pasteur.fr
Reply-To: njoly@pasteur.fr
To: gnats-bugs@gnats.NetBSD.org
Subject: lock error with mknod(2) & S_IFMT on tmpfs
X-Send-Pr-Version: 3.95

>Number:         41006
>Category:       kern
>Synopsis:       lock error with mknod(2) & S_IFMT on tmpfs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 13 16:25:00 +0000 2009
>Closed-Date:    Thu Mar 19 14:08:40 +0000 2009
>Last-Modified:  Tue Mar 24 20:25:01 +0000 2009
>Originator:     Nicolas Joly
>Release:        NetBSD 5.99.8
>Organization:
Institut Pasteur
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 5.99.8 NetBSD 5.99.8 (LANFEUST) #5: Fri Mar 13 14:30:02 CET 2009 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST amd64
Architecture: x86_64
Machine: amd64
>Description:
When running twice a mknod(2) & S_IFMT call on a tmpfs filesystem, the kernel
panics with `lock error'.

root@lanfeust [/tmp]# df -h .
Filesystem        Size       Used      Avail %Cap Mounted on
tmpfs              12G        40K        12G   0% /tmp
root@lanfeust [/tmp]# cat mknod.c
#include <sys/stat.h>
#include <sys/types.h>
#include <err.h>

#define TEST_FILE "mknod.test"

int main() {
  int res;
  dev_t nul;

  nul = makedev(2, 2);

  res = mknod(TEST_FILE, S_IFMT|0666, nul);
  if (res == -1)
    err(1, "mknod failed");

  return 0; }
root@lanfeust [/tmp]# make mknod
cc -O2   -o mknod mknod.c
root@lanfeust [/tmp]# ./mknod
mknod: mknod failed: Invalid argument
root@lanfeust [/tmp]# ./mknod
[...PANIC...]

panic: lock error
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip ffffffff80238775 cs 8 rflags 246 cr2  7f7ffce00440 cpl 0
rsp ffff800049b434a0
Stopped in pid 526.1 (zsh) at   netbsd:breakpoint+0x5:  leave
db{1}> mach cpu 0
using CPU 0
db{1}> bt
x86_stihlt() at netbsd:x86_stihlt+0x6
idle_loop() at netbsd:idle_loop+0x18e
db{1}> mach cpu 1
using CPU 1
db{1}> bt
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x289
lockdebug_abort() at netbsd:lockdebug_abort+0x42
rw_vector_enter() at netbsd:rw_vector_enter+0x2ea
vlockmgr() at netbsd:vlockmgr+0xf6
VOP_LOCK() at netbsd:VOP_LOCK+0x64
vn_lock() at netbsd:vn_lock+0xd9
namei() at netbsd:namei+0x174
check_exec() at netbsd:check_exec+0x40
execve1() at netbsd:execve1+0x2e5
syscall() at netbsd:syscall+0xb6

A quick look into this, show that S_IFMT is not supported on tmpfs, and thus
returning EINVAL. But it seems that the parent vnode remains locked in this
case ...
>How-To-Repeat:
Compile and run the provided testcase twice on a tmpfs filesystem with
appropriate privileges.
>Fix:
n/a

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->analyzed
State-Changed-By: pooka@NetBSD.org
State-Changed-When: Thu, 19 Mar 2009 16:48:56 +0300
State-Changed-Why:
fixed in tmpfs.  however, seems there's more problems here


From: Antti Kantee <pooka@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41006 CVS commit: src/sys/fs/tmpfs
Date: Thu, 19 Mar 2009 13:47:32 +0000

 Module Name:	src
 Committed By:	pooka
 Date:		Thu Mar 19 13:47:32 UTC 2009

 Modified Files:
 	src/sys/fs/tmpfs: tmpfs_vnops.c

 Log Message:
 Release dvp in mknod error branch.

 Nicolas Joly, PR kern/41006


 To generate a diff of this commit:
 cvs rdiff -u -r1.53 -r1.54 src/sys/fs/tmpfs/tmpfs_vnops.c

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

From: Antti Kantee <pooka@cs.hut.fi>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/41006
Date: Thu, 19 Mar 2009 15:48:02 +0200

 Indeed.  p2k has an assert which notices this even earlier:
 pain-rustique:5:~> rump_tmpfs sdf /puffs
 assertion "RUMP_VOP_ISLOCKED(opc) == 0" failed: file "p2k.c", line 513, function "p2k_node_mknod"
 Abort (core dumped)
 pain-rustique:6:~> 

 I fixed the tmpfs error branch.  However, it seems ffs doesn't like this
 program at all and creates a totally bogus file.

 Might be worthwhile to investigate other file systems.  Also, the mknod
 path should be looked at, but I don't have time to do it now.

State-Changed-From-To: analyzed->closed
State-Changed-By: pooka@NetBSD.org
State-Changed-When: Thu, 19 Mar 2009 17:08:40 +0300
State-Changed-Why:
As pointed out by bad, the ffs behaviour is actually how badsect works.


From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41006 CVS commit: [netbsd-5] src/sys/fs/tmpfs
Date: Tue, 24 Mar 2009 20:22:44 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Tue Mar 24 20:22:44 UTC 2009

 Modified Files:
 	src/sys/fs/tmpfs [netbsd-5]: tmpfs_vnops.c

 Log Message:
 Pull up following revision(s) (requested by pooka in ticket #590):
 	sys/fs/tmpfs/tmpfs_vnops.c: revision 1.54
 Release dvp in mknod error branch.
 Nicolas Joly, PR kern/41006


 To generate a diff of this commit:
 cvs rdiff -u -r1.51.6.1 -r1.51.6.2 src/sys/fs/tmpfs/tmpfs_vnops.c

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.