[PATCH] [2.6.0-test5] Severe data corruption on JFS

From: Dave Kleikamp
Date: Tue Sep 16 2003 - 07:37:51 EST


This patch fixes a severe data corruption problem in JFS on the
2.6.0-test5 kernel.

Andrew,
Please apply this to the -mm kernel.

Thanks,
Shaggy

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1315 -> 1.1316
# fs/jfs/jfs_imap.c 1.25 -> 1.26
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/16 shaggy@xxxxxxxxxxxxxxxxxxxxx 1.1316
# JFS: Fix rampant data corruption
#
# A recent change causes pervasive data corruption by over-writing inode
# metadata with a word of garbage. The field, di_rdev, should only be set
# for a device inode.
# --------------------------------------------
#
diff -Nru a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
--- a/fs/jfs/jfs_imap.c Tue Sep 16 07:25:50 2003
+++ b/fs/jfs/jfs_imap.c Tue Sep 16 07:25:50 2003
@@ -3041,10 +3041,11 @@
jfs_ip->next_index = le32_to_cpu(dip->di_next_index);
jfs_ip->otime = le32_to_cpu(dip->di_otime.tv_sec);
jfs_ip->acltype = le32_to_cpu(dip->di_acltype);
- jfs_ip->dev = le32_to_cpu(dip->di_rdev);

- if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode))
+ if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) {
+ jfs_ip->dev = le32_to_cpu(dip->di_rdev);
ip->i_rdev = old_decode_dev(jfs_ip->dev);
+ }

if (S_ISDIR(ip->i_mode)) {
memcpy(&jfs_ip->i_dirtable, &dip->di_dirtable, 384);
@@ -3101,7 +3102,8 @@
dip->di_otime.tv_sec = cpu_to_le32(jfs_ip->otime);
dip->di_otime.tv_nsec = 0;
dip->di_acltype = cpu_to_le32(jfs_ip->acltype);
- dip->di_rdev = cpu_to_le32(jfs_ip->dev);
+ if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode))
+ dip->di_rdev = cpu_to_le32(jfs_ip->dev);
}

#ifdef _JFS_DEBUG_IMAP
-
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/