mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG][PATCH] files on readonly filesystems could be truncated (patch for cramfs)
@ 2002-11-18  3:12 Peter Kundrat
  0 siblings, 0 replies; only message in thread
From: Peter Kundrat @ 2002-11-18  3:12 UTC (permalink / raw)
  To: quinlan; +Cc: viro, linux-kernel

Hi,

This patch solves the 2 problems:
1) cramfs is not marked readonly and it is possible to
   truncate files on it. This part is obvious and trivial.
2) Even setting MS_RDONLY in cramfs_read_super is not enough,
   since remount -wno remount still makes it possible (the same
   seems to be valid for all readonly filesystems).
   I solved it implementing super_operations.remount_fs.
   Is it a desired way of solving the problem ? If so,
   i could do the same for the others as well (isofs, romfs).

Although patch was diffed against 2.4.3, it still applies (at least
against 2.4.20-rc1).  Bug is present in 2.4 as well as in 2.5.

        Regards,

                        pkx


-- 
Peter Kundrat
peter@kundrat.sk

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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-18  3:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-18  3:12 [BUG][PATCH] files on readonly filesystems could be truncated (patch for cramfs) Peter Kundrat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®