mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Boldyshev <konst@linuxassembly.org>
To: linux-kernel@vger.kernel.org
Cc: marcelo.tosatti@cyclades.com
Subject: minix fs corruption fix for 2.4
Date: Mon, 3 Nov 2003 16:21:59 +0300 (MSK)	[thread overview]
Message-ID: <Pine.LNX.4.43L.0311031557480.1077-200000@alpha.linuxassembly.org> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1098 bytes --]

Hello,

Enclosed is a simple patch to fix corruption of minix filesystem
when deleting character and block device nodes (special files).
>From what I've found out the bug was introduced somehwere in 2.3
and is present in all 2.4 versions, and I guess also goes into 2.6.
Older 2.0 and 2.2 kernels do not have it - it seems that one who
was rewriting fs code for 2.4 just forgot to add the needed check.

Note that other filesystems that are rarely used nowdays may have
the same bug, especially if they used minix code as a template.


diff -urN linux-2.4.22/fs/minix/itree_common.c linux/fs/minix/itree_common.c
--- linux-2.4.22/fs/minix/itree_common.c	Thu Oct 16 11:30:27 2003
+++ linux/fs/minix/itree_common.c	Mon Nov  3 12:25:20 2003
@@ -301,6 +301,12 @@
 	int first_whole;
 	long iblock;

+	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
+	    S_ISLNK(inode->i_mode)))
+		return;
+	if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
+		return;
+
 	iblock = (inode->i_size + BLOCK_SIZE-1) >> 10;
 	block_truncate_page(inode->i_mapping, inode->i_size, get_block);


-- 
Regards,
Konstantin

[-- Attachment #2: Type: TEXT/PLAIN, Size: 555 bytes --]

diff -urN linux-2.4.22/fs/minix/itree_common.c linux/fs/minix/itree_common.c
--- linux-2.4.22/fs/minix/itree_common.c	Thu Oct 16 11:30:27 2003
+++ linux/fs/minix/itree_common.c	Mon Nov  3 12:25:20 2003
@@ -301,6 +301,12 @@
 	int first_whole;
 	long iblock;
 
+	if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
+	    S_ISLNK(inode->i_mode)))
+		return;
+	if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
+		return;
+
 	iblock = (inode->i_size + BLOCK_SIZE-1) >> 10;
 	block_truncate_page(inode->i_mapping, inode->i_size, get_block);
 

             reply	other threads:[~2003-11-03 13:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-03 13:21 Konstantin Boldyshev [this message]
2003-11-03 16:55 ` Linus Torvalds
2003-11-03 17:19   ` viro
2003-11-03 17:50     ` Linus Torvalds
2003-11-04  6:30   ` Konstantin Boldyshev

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=Pine.LNX.4.43L.0311031557480.1077-200000@alpha.linuxassembly.org \
    --to=konst@linuxassembly.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.tosatti@cyclades.com \
    /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®