Re: funlink() for fun!

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg A. Woods
Date: Monday, July 14, 2003 - 1:58 pm

[ On Monday, July 14, 2003 at 21:46:15 (+0200), Matthias Buelow wrote: ]

Oh, I know they're not exactly what you meant, but you can't (easily)
have what you meant -- it's next to impossible (and certainly not ever
practical) to implement what you wanted with any unix-like hierarchical
filesystem that allows multiple hard links and rename operations on
directories.

What you're suggesting is massively more complex and obviously much more
invasive than my simple little funlink(2) idea!  ;-)

(and it doesn't seem to offer much beyond what funlink() and/or
O_NOACESS (and maybe O_MKDIR) can offer)


But a directory handle isn't a representation of a pathname (though one
can intuit the name of the directory by walking back down to the root
directory and ascertaining the pathnames of each previous directory
along the way).

You'd have to do this for all the directories in the path, and you'd
have to somehow lock all the directories in the path in order to make
sure that every rename() involving any such directory could
co-operatively update those handles.

I.e. you're just beginning to enter the twisty little maze of passages
all alike.


If you want to keep the open(2) API intact then you could try to
implement it as a function call that's the moral equivalent of
fhopen(getfh(path)).  Either way the only logical thing to do (without
affecting the open() API) is to make it easy to translate a file
descriptor back into the file handle it came from.

I haven't thought of the implications of having file descriptors in
user-land, though presumably everything could be transmuted to use file
handles, including even descriptor passing through AF_LOCAL sockets.
The tricky parts involve seek pointers and such -- and that's something
I always get very confused about unless I diagram it all out on a big
sheet of paper.


That's part of the problem, not the solution.  Please study the example
safe_dir() implementation in the book I referenced.  You can find it in
here:

	http://www.buildingsecuresoftware.com/bss_examples-1.0.tar.gz

(in the file "EX9-5")


Unfortunately that's not (yet) true.  To quote from the fhopen(2) manual
page on NetBSD:

     These functions provide a means to access a file given the file handle
     fhp.  As this method bypasses directory access restrictions, these calls
     are restricted to the superuser.

fhopen() and fhchdir() would have to have full permissions checks added
to them.  In the fhchdir() case, for example, the operation would have
to be failed with EACCESS if the directory was not searchable by the
effective user or group of the caller.  Such an implementation of
fhchdir() would truly eliminate the need for der Mouse's O_NOACCESS.

As always though, the problem with new system calls that "violate"
various assumptions about levels of protection in an OS there are risks
that cannot easily be predicted.  getfh() suffers many the same kinds of
problems that procfs did, and that some ptrace() features still do.  One
would have to do some extrememly careful and detailed goal-oriented
analysis of the potential vulnerabilities before one took on the task of
making getfh() et al available to unprivileged users.

I seem to recall some more specific discussion on the issues with
providing secure unprivileged use of getfh() and fhopen() and so on, but
I forget where and what the details were.

-- 
						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>          Secrets of the Weird <woods@weird.com>
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: fsync performance hit on 1.6.1, Daniel Brewer, (Mon Jul 7, 12:45 am)
Re: fsync performance hit on 1.6.1, der Mouse, (Mon Jul 7, 12:53 am)
Re: fsync performance hit on 1.6.1, Chuck Silvers, (Mon Jul 7, 9:33 am)
Re: fsync performance hit on 1.6.1, Chuck Silvers, (Mon Jul 7, 9:39 am)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Mon Jul 7, 11:45 am)
Re: fsync performance hit on 1.6.1, David Laight, (Mon Jul 7, 1:58 pm)
Re: fsync performance hit on 1.6.1, Jochen Kunz, (Tue Jul 8, 1:16 am)
Re: fsync performance hit on 1.6.1, David Laight, (Tue Jul 8, 5:17 am)
Re: fsync performance hit on 1.6.1, Matthias Buelow, (Tue Jul 8, 11:18 am)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Tue Jul 8, 1:57 pm)
Re: fsync performance hit on 1.6.1, Matthias Buelow, (Tue Jul 8, 3:32 pm)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Tue Jul 8, 6:59 pm)
Re: fsync performance hit on 1.6.1, Matthias Buelow, (Tue Jul 8, 7:54 pm)
Re: fsync performance hit on 1.6.1, der Mouse, (Tue Jul 8, 8:09 pm)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Tue Jul 8, 8:44 pm)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Wed Jul 9, 12:01 am)
Re: fsync performance hit on 1.6.1, der Mouse, (Wed Jul 9, 12:11 am)
Re: fsync performance hit on 1.6.1, Christoph Hellwig, (Wed Jul 9, 1:04 am)
Re: fsync performance hit on 1.6.1, Christoph Hellwig, (Wed Jul 9, 1:07 am)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Wed Jul 9, 1:36 am)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Wed Jul 9, 9:26 am)
Re: fsync performance hit on 1.6.1, Christoph Hellwig, (Wed Jul 9, 9:43 am)
Re: fsync performance hit on 1.6.1, Matt Thomas, (Wed Jul 9, 11:13 am)
POSIX shm_open() vs. mmap(MAP_ANON|MAP_SHARED)...., Greg A. Woods, (Wed Jul 9, 11:17 am)
Re: fsync performance hit on 1.6.1, Matthias Buelow, (Wed Jul 9, 11:34 am)
Re: fsync performance hit on 1.6.1, Matthias Buelow, (Wed Jul 9, 11:43 am)
Re: fsync performance hit on 1.6.1, der Mouse, (Wed Jul 9, 12:21 pm)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Wed Jul 9, 12:22 pm)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Wed Jul 9, 12:56 pm)
Re: fsync performance hit on 1.6.1, der Mouse, (Wed Jul 9, 1:05 pm)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Wed Jul 9, 1:40 pm)
Re: fsync performance hit on 1.6.1, der Mouse, (Wed Jul 9, 1:50 pm)
Re: fsync performance hit on 1.6.1, Greywolf, (Wed Jul 9, 2:06 pm)
Re: fsync performance hit on 1.6.1, Christoph Hellwig, (Wed Jul 9, 5:14 pm)
Re: fsync performance hit on 1.6.1, Matthias Buelow, (Wed Jul 9, 6:32 pm)
Re: fsync performance hit on 1.6.1, Kamal R Prasad, (Wed Jul 9, 11:11 pm)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Thu Jul 10, 12:06 am)
Re: fsync performance hit on 1.6.1, Kamal R Prasad, (Thu Jul 10, 12:23 am)
Re: funlink() for fun!, Greg A. Woods, (Thu Jul 10, 9:35 am)
Re: POSIX shm_open() vs. mmap(MAP_ANON|MAP_SHARED)...., Greg A. Woods, (Thu Jul 10, 9:37 am)
Re: fsync performance hit on 1.6.1, Greg A. Woods, (Thu Jul 10, 9:40 am)
Re: funlink() for fun!, Greywolf, (Thu Jul 10, 2:52 pm)
Re: fsync performance hit on 1.6.1, Matthew Mondor, (Thu Jul 10, 3:08 pm)
Re: funlink() for fun!, Greg A. Woods, (Thu Jul 10, 3:34 pm)
Re: funlink() for fun!, Greywolf, (Thu Jul 10, 3:51 pm)
Re: funlink() for fun!, Greg A. Woods, (Thu Jul 10, 4:56 pm)
Re: funlink() for fun!, Greywolf, (Thu Jul 10, 5:31 pm)
Re: funlink() for fun!, der Mouse, (Thu Jul 10, 8:41 pm)
Re: funlink() for fun!, Greg A. Woods, (Thu Jul 10, 11:38 pm)
Re: funlink() for fun!, der Mouse, (Thu Jul 10, 11:43 pm)
Re: funlink() for fun!, Greg A. Woods, (Fri Jul 11, 12:31 am)
Re: funlink() for fun!, der Mouse, (Fri Jul 11, 1:12 am)
Re: funlink() for fun!, David Laight, (Fri Jul 11, 2:36 am)
Re: funlink() for fun!, Roland Dowdeswell, (Fri Jul 11, 8:03 am)
Re: funlink() for fun!, Greg A. Woods, (Fri Jul 11, 10:47 am)
Re: funlink() for fun!, Greg A. Woods, (Fri Jul 11, 10:58 am)
Re: funlink() for fun!, Greywolf, (Fri Jul 11, 1:42 pm)
Re: funlink() for fun!, der Mouse, (Fri Jul 11, 1:48 pm)
Re: funlink() for fun!, Greg A. Woods, (Fri Jul 11, 4:02 pm)
Re: funlink() for fun!, Greywolf, (Fri Jul 11, 4:20 pm)
Re: funlink() for fun!, Matthias Buelow, (Fri Jul 11, 6:38 pm)
Re: funlink() for fun!, Matthias Buelow, (Fri Jul 11, 6:53 pm)
Re: funlink() for fun!, Greywolf, (Fri Jul 11, 7:20 pm)
Re: funlink() for fun!, Greg A. Woods, (Sat Jul 12, 1:11 am)
Re: funlink() for fun!, Greg A. Woods, (Sat Jul 12, 1:47 am)
Re: funlink() for fun!, Greg A. Woods, (Sat Jul 12, 1:54 am)
Re: funlink() for fun!, der Mouse, (Sat Jul 12, 1:57 am)
Re: funlink() for fun!, Greywolf, (Sat Jul 12, 2:11 am)
Re: funlink() for fun!, joerg, (Sat Jul 12, 4:07 am)
Re: funlink() for fun!, Ignatios Souvatzis, (Sat Jul 12, 6:18 am)
Re: funlink() for fun!, Greg A. Woods, (Sat Jul 12, 10:48 am)
Re: funlink() for fun!, Greg A. Woods, (Sat Jul 12, 10:57 am)
Re: funlink() for fun!, Matthias Buelow, (Sun Jul 13, 1:25 pm)
Re: funlink() for fun!, Greg A. Woods, (Sun Jul 13, 3:58 pm)
Re: funlink() for fun!, Matthias Buelow, (Mon Jul 14, 7:19 am)
Re: funlink() for fun!, Greg A. Woods, (Mon Jul 14, 9:08 am)
Re: funlink() for fun!, Greywolf, (Mon Jul 14, 9:24 am)
Re: funlink() for fun!, Matthias Buelow, (Mon Jul 14, 9:34 am)
Re: funlink() for fun!, Greg A. Woods, (Mon Jul 14, 10:44 am)
Re: funlink() for fun!, Ben Harris, (Mon Jul 14, 11:06 am)
Re: funlink() for fun!, Greywolf, (Mon Jul 14, 11:20 am)
Re: funlink() for fun!, Greg A. Woods, (Mon Jul 14, 11:30 am)
Re: funlink() for fun!, Matthias Buelow, (Mon Jul 14, 12:46 pm)
Re: funlink() for fun!, Matthias Buelow, (Mon Jul 14, 1:51 pm)
Re: funlink() for fun!, Greg A. Woods, (Mon Jul 14, 1:58 pm)
Re: funlink() for fun!, Greg A. Woods, (Mon Jul 14, 2:43 pm)
Re: funlink() for fun!, der Mouse, (Mon Jul 14, 3:00 pm)
Re: funlink() for fun!, Greywolf, (Mon Jul 14, 4:05 pm)
Re: funlink() for fun!, der Mouse, (Mon Jul 14, 4:56 pm)
Re: funlink() for fun!, Greg A. Woods, (Mon Jul 14, 5:07 pm)
Re: funlink() for fun!, der Mouse, (Mon Jul 14, 5:42 pm)
re: funlink() for fun!, matthew green, (Mon Jul 14, 8:55 pm)
re: funlink() for fun!, Bill Studenmund, (Tue Jul 15, 10:31 am)
Re: funlink() for fun!, Bill Studenmund, (Tue Jul 15, 10:34 am)
Re: funlink() for fun!, Bill Studenmund, (Tue Jul 15, 11:47 am)
Re: funlink() for fun!, Bill Studenmund, (Tue Jul 15, 12:00 pm)
Re: funlink() for fun!, ww, (Tue Jul 15, 12:09 pm)
Re: funlink() for fun!, Bill Studenmund, (Tue Jul 15, 12:40 pm)
Re: funlink() for fun!, der Mouse, (Tue Jul 15, 12:49 pm)
Re: funlink() for fun!, Ignatios Souvatzis, (Tue Jul 15, 1:02 pm)
Re: funlink() for fun!, Bill Studenmund, (Tue Jul 15, 1:28 pm)
Re: funlink() for fun!, Greg A. Woods, (Wed Jul 16, 12:05 am)