[comp.os.minix] fs/mm interface bug discovered and fixed

bammi@dsrgsun.ces.cwru.edu (Jwahar R. Bammi) (11/29/89)

i am posting this for a friend Kai-Uwe who has been having problems posting
to info-minix. please follow up to him at:

Kai-Uwe Bloem, I5110401@DBSTU1.BitNet, ...!unido!dbstu1.bitnet!i5110401,
I5110401%DBSTU1.BITNET@CORNELLC.CCS.CORNELL.EDU (or other known gateways)

---------
Subject: fs/mm interface bug discovered and fixed (and some minor cleanups)

hello all,
some time ago i discovered a bug in the mm/fs interface. Namely you must have
read rights to execute a file. I found this is a conceptual problem in the
interface between mm and fs. mm does an open(name,0) and an fstat(fd) call
to check the permissions for the file. However, the open call can only succeed
if you have read rights on the file, because mm temporarily switches to the
users working directory and the users effective uid/gid.

The problem is fixed by doing a dirty trick similar to that used by mm to tell
fs the address of the data in a read/write call : pass the access bits desired
by mm directly in the open call (i use bits 12-15 for that). do_open() now
recognizes this and take those bits instead of calculating its own set of bits
from the given access mode. The read code has been modified to allow read on
a file with only the x-bit set. The user can't set this bit in the file
descriptor, so this should not do any harm.

Another problem i found was with mounted file systems : the file system gets
bus errors when crossing from the mounted file system to the mounted-on file
system and you don't have the permission to search the mount-on directory.
I found no obvious solution to this, but the bus error can be avoided by
an extension in a while condition. Ideas for soultion, anyone ? What happens
on real UNIX in this case ?

The cdiff set also contains some minor cleanups i've done to the fs code,
mostly inconsistent use of sizeof(super_block) where SUPER_SIZE should be
used.

uuencoded compressed cdiff file follows. Copy to /usr/src (or where else your
minix source tree is located) and call patch on it.

Regards,
=========================================================================
              " This space intentionally left blank "

Kai-Uwe Bloem, I5110401@DBSTU1.BitNet, ...!unido!dbstu1.bitnet!i5110401,
I5110401%DBSTU1.BITNET@CORNELLC.CCS.CORNELL.EDU (or other known gateways)
   student of cs at Technische Universitaet Braunschweig / w-germany

ps: i'm no longer able to post things to info-minix@udel.edu directly. Has
someone mentioned similar problems and found a solution for it ?
===snip===snip===snip===snip===snip===snip===snip===snip===snip===snip===
table
 !"#$%&'()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