[UPDATE][PATCH 2/2] ext2: enlarge blocksize and fix rec_lenoverflow

From: sho
Date: Fri Jul 07 2006 - 07:52:06 EST


[2/2] ext2: fix rec_len overflow
- prevent rec_len from overflow with 64KB blocksize

Signed-off-by: Takashi Sato sho@xxxxxxxxxxxxxx
---
diff -Nupr -X linux-2.6.17-git13-Mingming/Documentation/dontdiff linux-2.6.17-git13-Mingming/fs/ext2/dir.c linux-2.6.17-git13-Mingming-reclen/fs/ext2/dir.c
--- linux-2.6.17-git13-Mingming/fs/ext2/dir.c 2006-07-07 17:24:11.000000000 +0900
+++ linux-2.6.17-git13-Mingming-reclen/fs/ext2/dir.c 2006-07-07 17:03:42.000000000 +0900
@@ -459,14 +459,23 @@ int ext2_add_link (struct dentry *dentry
kaddr = page_address(page);
dir_end = kaddr + ext2_last_byte(dir, n);
de = (ext2_dirent *)kaddr;
- kaddr += PAGE_CACHE_SIZE - reclen;
+ if (chunk_size < EXT2_DIR_MAX_REC_LEN)
+ kaddr += PAGE_CACHE_SIZE - reclen;
+ else
+ kaddr += EXT2_DIR_MAX_REC_LEN - reclen;
while ((char *)de <= kaddr) {
if ((char *)de == dir_end) {
/* We hit i_size */
name_len = 0;
- rec_len = chunk_size;
- de->rec_len = cpu_to_le16(chunk_size);
de->inode = 0;
+ if (chunk_size < EXT2_DIR_MAX_REC_LEN) {
+ rec_len = chunk_size;
+ de->rec_len = cpu_to_le16(chunk_size);
+ } else {
+ rec_len = EXT2_DIR_MAX_REC_LEN;
+ de->rec_len =
+ cpu_to_le16(EXT2_DIR_MAX_REC_LEN);
+ }
goto got_it;
}
if (de->rec_len == 0) {
diff -Nupr -X linux-2.6.17-git13-Mingming/Documentation/dontdiff linux-2.6.17-git13-Mingming/include/linux/ext2_fs.h linux-2.6.17-git13-Mingming-reclen/include/linux/ext2_fs.h
--- linux-2.6.17-git13-Mingming/include/linux/ext2_fs.h 2006-07-07 17:24:12.000000000 +0900
+++ linux-2.6.17-git13-Mingming-reclen/include/linux/ext2_fs.h 2006-07-07 14:43:34.000000000 +0900
@@ -90,8 +90,8 @@ static inline struct ext2_sb_info *EXT2_
* Macro-instructions used to manage several block sizes
*/
#define EXT2_MIN_BLOCK_SIZE 1024
-#define EXT2_MAX_BLOCK_SIZE 4096
-#define EXT2_MIN_BLOCK_LOG_SIZE 10
+#define EXT2_MAX_BLOCK_SIZE 65536
+#define EXT2_MIN_BLOCK_LOG_SIZE 10
#ifdef __KERNEL__
# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
#else
@@ -553,5 +553,6 @@ enum {
#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
~EXT2_DIR_ROUND)
+#define EXT2_DIR_MAX_REC_LEN 65532

#endif /* _LINUX_EXT2_FS_H */


Cheers sho
-
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/