Subject: kern/2423: bugs in union-mounts
To: None <gnats-bugs@NetBSD.ORG>
From: Andrew Wheadon <andrew@wipux2.wifo.uni-mannheim.de>
List: netbsd-bugs
Date: 05/16/1996 18:06:11
>Number:         2423
>Category:       kern
>Synopsis:       union mounts panic when unmounting, panic when done twice
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 16 12:50:03 1996
>Last-Modified:
>Originator:     Andrew Wheadon
>Organization:
The cost of living hasn't affected it's popularity. (Mark Twain)
current	release=doc host=wipux2.wifo.uni-mannheim.de \ "NetBSD-current mirror"
hostbase=/mit/ftp/pub/NetBSD base=/usr prefix=/usr backup delete use-rel-suffix
>Release:        15.05.96
>Environment:
	
System: NetBSD wipux2 1.1B NetBSD 1.1B (WIPOOL) #0: Thu May 16 14:57:24 MET DST 1996 toor@wipux2:/src/src/sys/arch/i386/compile/WIPOOL i386


>Description:
three bugs:	1) panics when unmounting, 2) allows double-mounting,
		which is followed by panic on access, 3) no dependencies
		explained when compiling kernel.
one nicety:	4) union-mounts are not nfs-exportable

1)
	Union mounts panic when trying to unmount them:
mount -t union -o -b /src2/boot/wippc00 /src2/boot/wippc51
ls /src2/boot/wippc51
umount /src2/boot/wippc51
	vgone
	vflush
	union_unmount
	dounmount
	sys_unmount
	syscall (22)

2)
	Union mounts are easily mounted twice over each other:

mount /src2/boot/wippc53
mount /src2/boot/wippc53
(this is the output of 'mount')
...
/dev/sd1g on /src2 type ffs (NFS exported, local)
<below>:/src2/boot/wippc00 on /src2/boot/wippc51 type union
<below>:/src2/boot/wippc00 on /src2/boot/wippc53 type union
<below>:/src2/boot/wippc00 on /src2/boot/wippc55 type union
<below>:/src2/boot/wippc00 on /src2/boot/wippc53 type union


	and when you then try to ls /src2/boot/wippc53 it (naturally)
	panics:
	panic locking against myself
	ufs_lock
	union_dir_cache
	sys_getdirentries
	syscall (196)
	(I have the (11mb compressed) core-dump for this one)

3)
	When compiling the Kernel and setting 'option UNION', unions
	will still fail to mount. At least one of the following additional
	options are needed to compile a kernel that supports UNION
	NULLFS,UMAPFS (probably NULLFS) but dependency is not defined
	in files*.

4)
<root@wipux2:/src2/boot> mount -v -t nfs wipux2:/src2/boot /mnt
wipux2:/src2/boot on /mnt type nfs
<root@wipux2:/src2/boot> ls /mnt/wippc53
.s      dev/    home/   root/   src2/   usr/
bin/    etc/    mnt/    sbin/   tmp/    var/
<root@wipux2:/src2/boot> mount
...
<below>:/src2/boot/wippc00 on /src2/boot/wippc53 type union
wipux2:/src2/boot on /mnt type nfs
...
<root@wipux2:/src2/boot> umount /mnt
<root@wipux2:/src2/boot> mount -v -t nfs wipux2:/src2/boot/wippc53 /mnt
nfs: can't access /src2/boot/wippc53: Permission denied
<root@wipux2:/src2/boot> umount /mnt

As you can tell mounting /src2/boot lets me see the file but
ignores the union, and just shows me truely local files. (ie. the kernel
file on wippc00/netbsd is not listed etc.)
Trying to mount the union-directory fails completely.

>How-To-Repeat:
	see above.
>Fix:
	1)	??? 
	2)	Do NOT permit mounting same stuff in same place twice.
	3)	somehow add dependencies for config.
	4)	???
>Audit-Trail:
>Unformatted: