Re: strange ext{3,4}_settattr logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mar 16, 2008  14:39 +0300, Dmitri Monakhov wrote:
> > --- linux-2.6.24/fs/namei.c.orig	2008-02-05 07:29:57.000000000 +0800
> > +++ linux-2.6.24/fs/namei.c	2008-03-16 08:11:41.000000000 +0800
> > @@ -233,6 +233,10 @@ int permission(struct inode *inode, int 
> >  	if (nd)
> >  		mnt = nd->mnt;
> >  
> > +	/* Don't allow direct read, write, or truncate on a swapfile */
>
> Your patch disallow expand truncates (#2) which is definitely not good. 

How often is that done though?  Since this is only for a swapfile then
it isn't needed.

> In fact if file was opened before S_SWAPFILE flag was setted when it is
> possible to directly read, write from file.

I assume that is even a more rare case.  I was thinking alternately to
do a "deny_write" on the swapfile during swapon() so that this would
fail in more cases.

> > +	if (IS_SWAPFILE(inode))
> > +		return -ETXTBUSY;
> > +
> >  	if (mask & MAY_WRITE) {
> >  		umode_t mode = inode->i_mode;
> 
> BTW it is impossible to disable swapfile with your patch 
> [root@ts63 tmp]# swapoff  /vz/swap 
> swapoff: /vz/swap: Text file busy

I thought some bug like this might appear.

> IMHO S_SWAPFILE flag must be checked in ext3_setattr, see patch attached:

No, that still means every other filesystem is broken.  Since the current
filesystem code doesn't know anything about IS_SWAPFILE I'd rather keep
it that way.  I think it is better to move my proposed IS_SWAPFILE() check
into "MAY_WRITE" and "MAY_EXEC" cases.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux