Subject: kern/1206: union file system botches permissions on copy-up files
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: None <jtk@kolvir.blrc.ma.us>
List: netbsd-bugs
Date: 07/10/1995 20:05:09
>Number:         1206
>Category:       kern
>Synopsis:       the union FS doesn't get permissions on copied-up files
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 10 20:05:04 1995
>Originator:     John T Kohl
>Organization:
NetBSD Kernel Hackers `R` Us
>Release:        -current, 5 July 1995
>Environment:
	
System: NetBSD lola-granola 1.0A NetBSD 1.0A (LOLA) #57: Sun Jun 11 23:51:12 EDT 1995 mycroft@lola-granola:/afs/sipb.mit.edu/project/netbsd/dev/current-source/src/sys/arch/i386/compile/LOLA i386

>Description:

When you do something that induces a copyup of a file in the union file
system, the union_copyup() routine does not set the mode bits/etc of the
file to match the copied-up file.  In particular, it never copies up
execute bits.

>How-To-Repeat:

Mount with the union FS.  Induce a copyup on a file with execute bits
set.  Look at the upper and lower perms, and notice they don't match:

% ls -l upper-level lower-level
lower-level:
total 16
-rwxr-xr-x  1 jtkohl  wheel  16384 Jul 10 19:53 man

upper-level:
% mount -t union upper-level lower-level
% mount |grep union
<above>:/u1/var/tmp/upper-level on /u1/var/tmp/lower-level type union (local, nodev, nosuid)
% cd lower-level
% ls -l
total 16
-rwxr-xr-x  1 jtkohl  wheel  16384 Jul 10 19:53 man
% cat /etc/motd >>man
% ls -l
total 17
-rw-r--r--  1 jtkohl  wheel  16457 Jul 10 19:54 man

>Fix:

There should probably be some variety of VOP_SETATTR() call inside
union_copyup().  Since the upper layer must support whiteouts, that
means (for now) it's always 4.4BSD FFS and it's quite easy to set any
attributes required.  The hard part (which I haven't thought about yet)
is exactly which attributes should be copied, and which should be set
explicitly based on the user's identity and the mounting user's
identity.

>Audit-Trail:
>Unformatted: