PATCH: linux-2.4.0-test5-pre4: cramfs corrupts ramdisk data

From: Adam J. Richter (adam@yggdrasil.com)
Date: Mon Jul 24 2000 - 05:38:56 EST


        cramfs was calling bforget() on every block that it read.
bforget() has a side effect of causing the corresponding block of a
ramdisk to be filled with zeroes.

        At first, I thought the correct fix was to change bforget to
just do a brelse if a page was marked with BH_Protected. However, on
closer inspection, it appears that everywhere else in the kernel
where bforget is called, it really is OK to wipe out the underlying
data (basically, deleted blocks). This is actually quite useful
for, say, a writable ext2 filesystem on a ramdisk device. So, I believe
the correct fix is for cramfs to call brelse instead of bforget.

        I have attached the patch below.

Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104
adam@yggdrasil.com \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."
---------------------------CUT HERE----------------------------------------

diff -u linux-2.4.0-test5-pre4/fs/cramfs/inode.c linux/fs/cramfs/inode.c
--- linux-2.4.0-test5-pre4/fs/cramfs/inode.c Tue May 23 14:52:18 2000
+++ linux/fs/cramfs/inode.c Sun May 28 01:38:13 2000
@@ -142,7 +142,7 @@
                 struct buffer_head * bh = bh_array[i];
                 if (bh) {
                         memcpy(data, bh->b_data, PAGE_CACHE_SIZE);
- bforget(bh);
+ brelse(bh);
                 } else
                         memset(data, 0, PAGE_CACHE_SIZE);
                 data += PAGE_CACHE_SIZE;

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



This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 21:00:16 EST