Re: minix fs corruption fix for 2.4

From: Linus Torvalds
Date: Mon Nov 03 2003 - 11:57:22 EST



On Mon, 3 Nov 2003, Konstantin Boldyshev wrote:
>
> 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.

Oops, yes.

The problem is that block and character devices put not a block number but
a _device_ number in the place where other files put their block
allocations.

Your patch is wrong, though - you shouldn't test for APPEND and IMMUTABLE
here. That should be done at higher layers.

I'd also prefer to do the test the other way around: test for CHRDEV and
BLKDEV in inode.c the same way the other functions do. Something like the
appended..

Al, can you verify? I think this crept in when you did the block lookup
cleanups. I also worry whether anybody else got the bug?

Linus

===== fs/minix/inode.c 1.38 vs edited =====
--- 1.38/fs/minix/inode.c Fri Sep 5 04:31:53 2003
+++ edited/fs/minix/inode.c Mon Nov 3 08:51:01 2003
@@ -547,6 +547,8 @@
*/
void minix_truncate(struct inode * inode)
{
+ if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
+ return;
if (INODE_VERSION(inode) == MINIX_V1)
V1_minix_truncate(inode);
else

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