linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* MS_RDONLY patch (do_remount_sb and cramfs/inode.c)
@ 2001-05-15  9:27 Peter Kundrat
  2001-05-15 10:24 ` Peter Kundrat
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Kundrat @ 2001-05-15  9:27 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Hello,

This patch does:
- set MS_RDONLY flag in cramfs superblock
- doesnt allow -w remount in do_remount_sb 
  if the filesystem has MS_RDONLY set.

Without it, it is possible to remount r/o
filesystem with -w and truncate files on it.
I hope that doesnt fall into 'dont do that then'
category.
Please apply.

	Regards,

		pkx

diff -ur -x *~ -x *.o -x .* Linux-2.4.3.orig/fs/cramfs/inode.c Linux-2.4.3.isdn.kgdb/fs/cramfs/inode.c
--- Linux-2.4.3.orig/fs/cramfs/inode.c	Fri Apr  6 08:09:07 2001
+++ Linux-2.4.3.isdn.kgdb/fs/cramfs/inode.c	Mon May 14 18:51:08 2001
@@ -192,6 +192,8 @@
 		goto out;
 	}
 
+	sb->s_flags |= MS_RDONLY;
+
 	/* Set it all up.. */
 	sb->s_op	= &cramfs_ops;
 	sb->s_root 	= d_alloc_root(get_cramfs_inode(sb, &super.root));
diff -ur -x *~ -x *.o -x .* Linux-2.4.3.orig/fs/super.c Linux-2.4.3.isdn.kgdb/fs/super.c
--- Linux-2.4.3.orig/fs/super.c	Fri Apr  6 08:09:08 2001
+++ Linux-2.4.3.isdn.kgdb/fs/super.c	Tue May 15 10:53:12 2001
@@ -944,7 +944,7 @@
 {
 	int retval;
 	
-	if (!(flags & MS_RDONLY) && sb->s_dev && is_read_only(sb->s_dev))
+	if (!(flags & MS_RDONLY) && ((sb->s_flags & MS_RDONLY) || sb->s_dev && is_read_only(sb->s_dev)))
 		return -EACCES;
 		/*flags |= MS_RDONLY;*/
 	/* If we are remounting RDONLY, make sure there are no rw files open */

-- 
Peter Kundrat
peter@kundrat.sk

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: MS_RDONLY patch (do_remount_sb and cramfs/inode.c)
  2001-05-15  9:27 MS_RDONLY patch (do_remount_sb and cramfs/inode.c) Peter Kundrat
@ 2001-05-15 10:24 ` Peter Kundrat
  2001-05-15 11:16   ` Peter Kundrat
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Kundrat @ 2001-05-15 10:24 UTC (permalink / raw)
  To: torvalds, linux-kernel

On Tue, May 15, 2001 at 11:27:26AM +0200, Peter Kundrat wrote:
> This patch does:
> - set MS_RDONLY flag in cramfs superblock
> - doesnt allow -w remount in do_remount_sb 
>   if the filesystem has MS_RDONLY set.

Oh, ignore the second part. Seems i'd have to supply remount_fs super
op to prevent that.

pkx
-- 
Peter Kundrat
peter@kundrat.sk

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: MS_RDONLY patch (do_remount_sb and cramfs/inode.c)
  2001-05-15 10:24 ` Peter Kundrat
@ 2001-05-15 11:16   ` Peter Kundrat
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Kundrat @ 2001-05-15 11:16 UTC (permalink / raw)
  To: torvalds, linux-kernel

On Tue, May 15, 2001 at 12:24:06PM +0200, Peter Kundrat wrote:
> On Tue, May 15, 2001 at 11:27:26AM +0200, Peter Kundrat wrote:
> > This patch does:
> > - set MS_RDONLY flag in cramfs superblock
> > - doesnt allow -w remount in do_remount_sb 
> >   if the filesystem has MS_RDONLY set.
> 
> Oh, ignore the second part. Seems i'd have to supply remount_fs super
> op to prevent that.

How about this one ? Similar thing could be done to other fs as well.
	
		pkx

diff -ur -x *~ -x *.o -x .* Linux-2.4.3.orig/fs/cramfs/inode.c Linux-2.4.3.isdn.kgdb/fs/cramfs/inode.c
--- Linux-2.4.3.orig/fs/cramfs/inode.c	Fri Apr  6 08:09:07 2001
+++ Linux-2.4.3.isdn.kgdb/fs/cramfs/inode.c	Tue May 15 12:56:32 2001
@@ -192,6 +192,8 @@
 		goto out;
 	}
 
+	sb->s_flags |= MS_RDONLY;
+
 	/* Set it all up.. */
 	sb->s_op	= &cramfs_ops;
 	sb->s_root 	= d_alloc_root(get_cramfs_inode(sb, &super.root));
@@ -212,6 +214,14 @@
 	return 0;
 }
 
+static int cramfs_remount (struct super_block * sb, int * flags, char * data)
+{
+	if (*flags & MS_RDONLY) 
+		return 0;
+	else
+		return -EROFS;
+}
+
 /*
  * Read a cramfs directory entry.
  */
@@ -358,6 +368,7 @@
 
 static struct super_operations cramfs_ops = {
 	statfs:		cramfs_statfs,
+	remount_fs:	cramfs_remount,
 };
 
 static DECLARE_FSTYPE_DEV(cramfs_fs_type, "cramfs", cramfs_read_super);
-- 
Peter Kundrat
peter@kundrat.sk

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-05-15 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-15  9:27 MS_RDONLY patch (do_remount_sb and cramfs/inode.c) Peter Kundrat
2001-05-15 10:24 ` Peter Kundrat
2001-05-15 11:16   ` Peter Kundrat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).