mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Kundrat <kundrat@kundrat.sk>
To: quinlan@transmeta.com
Cc: viro@math.psu.edu, linux-kernel@vger.kernel.org
Subject: [BUG][PATCH] files on readonly filesystems could be truncated (patch for cramfs)
Date: Mon, 18 Nov 2002 04:12:15 +0100	[thread overview]
Message-ID: <20021118031215.GA14047@napri.sk> (raw)

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

                 reply	other threads:[~2002-11-18  3:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021118031215.GA14047@napri.sk \
    --to=kundrat@kundrat.sk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quinlan@transmeta.com \
    --cc=viro@math.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®