Re: [patch-2.4.0-test12-pre6] truncate(2) permissions

From: Alexander Viro (viro@math.psu.edu)
Date: Wed Dec 06 2000 - 17:38:31 EST


On Wed, 6 Dec 2000, Linus Torvalds wrote:

>
>
> On Wed, 6 Dec 2000, Tigran Aivazian wrote:
> >
> > This patch combines your previous patch with 2 changes I have just
> > suggested. Both changes are obvious (and correct).
>
> Why remove the EROFS test?

Tigran has a point - permission() does

        if ((mask & S_IWOTH) && IS_RDONLY(inode) &&
                 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
                return -EROFS; /* Nobody gets write access to a read-only fs */

so do_sys_truncate() has no chance in hell to trigger its own check for
IS_RDONLY() - we have

        if (!S_ISREG(inode->i_mode))
                goto dput_and_out;

        error = permission(inode,MAY_WRITE);
        if (error)
                goto dput_and_out;

        error = -EROFS;
        if (IS_RDONLY(inode))
                goto dput_and_out;

there, so if it's not a regular file we die before the call of permission(),
if it is and fs is readonly - we get -EROFS from permission() and die
there. In either case we don't get to the IS_RDONLY() check...

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Dec 07 2000 - 21:00:16 EST