All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] dump.f2fs: show extra attr only when feature is enabled
@ 2017-11-16 11:50 ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

If we don't turn on the feature, don't show related info in dumped data.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/mount.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 653dcf391da7..c094f940ee1b 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -222,10 +222,15 @@ void print_inode_info(struct f2fs_sb_info *sbi,
 			le32_to_cpu(inode->i_ext.blk_addr),
 			le32_to_cpu(inode->i_ext.len));
 
-	DISP_u16(inode, i_extra_isize);
-	DISP_u16(inode, i_inline_xattr_size);
-	DISP_u32(inode, i_projid);
-	DISP_u32(inode, i_inode_checksum);
+	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
+		DISP_u16(inode, i_extra_isize);
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_FLEXIBLE_INLINE_XATTR))
+			DISP_u16(inode, i_inline_xattr_size);
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
+			DISP_u32(inode, i_projid);
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM))
+			DISP_u32(inode, i_inode_checksum);
+	}
 
 	DISP_u32(inode, i_addr[ofs]);		/* Pointers to data blocks */
 	DISP_u32(inode, i_addr[ofs + 1]);	/* Pointers to data blocks */
-- 
2.15.0.55.gc2ece9dc4de6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/4] dump.f2fs: show extra attr only when feature is enabled
@ 2017-11-16 11:50 ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

If we don't turn on the feature, don't show related info in dumped data.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/mount.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 653dcf391da7..c094f940ee1b 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -222,10 +222,15 @@ void print_inode_info(struct f2fs_sb_info *sbi,
 			le32_to_cpu(inode->i_ext.blk_addr),
 			le32_to_cpu(inode->i_ext.len));
 
-	DISP_u16(inode, i_extra_isize);
-	DISP_u16(inode, i_inline_xattr_size);
-	DISP_u32(inode, i_projid);
-	DISP_u32(inode, i_inode_checksum);
+	if (c.feature & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
+		DISP_u16(inode, i_extra_isize);
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_FLEXIBLE_INLINE_XATTR))
+			DISP_u16(inode, i_inline_xattr_size);
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA))
+			DISP_u32(inode, i_projid);
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM))
+			DISP_u32(inode, i_inode_checksum);
+	}
 
 	DISP_u32(inode, i_addr[ofs]);		/* Pointers to data blocks */
 	DISP_u32(inode, i_addr[ofs + 1]);	/* Pointers to data blocks */
-- 
2.15.0.55.gc2ece9dc4de6


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] fsck.f2fs: fix potential stack overflow issue
  2017-11-16 11:50 ` Chao Yu
@ 2017-11-16 11:50   ` Chao Yu
  -1 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

In fsck_chk_inode_blk, we will allocate 256 bytes memory in stack before
traversing sub-directory recursively, it's not safe, in order to avoid
potential stack overflow, use malloc instead.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/fsck.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index ec8871278464..11b8b0b8303d 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -633,7 +633,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 	u64 i_size = le64_to_cpu(node_blk->i.i_size);
 	u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
 	int ofs = get_extra_isize(node_blk);
-	unsigned char en[F2FS_NAME_LEN + 1];
+	unsigned char *en;
 	int namelen;
 	unsigned int idx = 0;
 	int need_fix = 0;
@@ -838,6 +838,9 @@ check:
 		}
 	}
 skip_blkcnt_fix:
+	en = malloc(F2FS_NAME_LEN + 1);
+	ASSERT(en);
+
 	namelen = convert_encrypted_name(node_blk->i.i_name,
 					le32_to_cpu(node_blk->i.i_namelen),
 					en, file_enc_name(&node_blk->i));
@@ -879,6 +882,9 @@ skip_blkcnt_fix:
 			}
 		}
 	}
+
+	free(en);
+
 	if (ftype == F2FS_FT_SYMLINK && i_blocks && i_size == 0) {
 		DBG(1, "ino: 0x%x i_blocks: %lu with zero i_size",
 						nid, (unsigned long)i_blocks);
-- 
2.15.0.55.gc2ece9dc4de6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] fsck.f2fs: fix potential stack overflow issue
@ 2017-11-16 11:50   ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

In fsck_chk_inode_blk, we will allocate 256 bytes memory in stack before
traversing sub-directory recursively, it's not safe, in order to avoid
potential stack overflow, use malloc instead.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/fsck.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index ec8871278464..11b8b0b8303d 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -633,7 +633,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 	u64 i_size = le64_to_cpu(node_blk->i.i_size);
 	u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
 	int ofs = get_extra_isize(node_blk);
-	unsigned char en[F2FS_NAME_LEN + 1];
+	unsigned char *en;
 	int namelen;
 	unsigned int idx = 0;
 	int need_fix = 0;
@@ -838,6 +838,9 @@ check:
 		}
 	}
 skip_blkcnt_fix:
+	en = malloc(F2FS_NAME_LEN + 1);
+	ASSERT(en);
+
 	namelen = convert_encrypted_name(node_blk->i.i_name,
 					le32_to_cpu(node_blk->i.i_namelen),
 					en, file_enc_name(&node_blk->i));
@@ -879,6 +882,9 @@ skip_blkcnt_fix:
 			}
 		}
 	}
+
+	free(en);
+
 	if (ftype == F2FS_FT_SYMLINK && i_blocks && i_size == 0) {
 		DBG(1, "ino: 0x%x i_blocks: %lu with zero i_size",
 						nid, (unsigned long)i_blocks);
-- 
2.15.0.55.gc2ece9dc4de6


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] f2fs: avoid memory leak in f2fs_write_root_inode
  2017-11-16 11:50 ` Chao Yu
@ 2017-11-16 11:50   ` Chao Yu
  -1 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

Before exiting f2fs_write_root_inode, we should free in-there allocated
memory.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 mkfs/f2fs_format.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index d5f39ca3dac4..9fc0398fab65 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1042,6 +1042,7 @@ static int f2fs_write_root_inode(void)
 			c.blks_per_seg, main_area_node_seg_blk_offset);
 	if (dev_write_block(raw_node, main_area_node_seg_blk_offset)) {
 		MSG(1, "\tError: While writing the raw_node to disk!!!\n");
+		free(raw_node);
 		return -1;
 	}
 
@@ -1052,9 +1053,11 @@ static int f2fs_write_root_inode(void)
 
 #ifndef WITH_ANDROID
 	if (discard_obsolete_dnode(raw_node, main_area_node_seg_blk_offset)) {
+		free(raw_node);
 		return -1;
 	}
 #endif
+	free(raw_node);
 	return 0;
 }
 
-- 
2.15.0.55.gc2ece9dc4de6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] f2fs: avoid memory leak in f2fs_write_root_inode
@ 2017-11-16 11:50   ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

Before exiting f2fs_write_root_inode, we should free in-there allocated
memory.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 mkfs/f2fs_format.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index d5f39ca3dac4..9fc0398fab65 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -1042,6 +1042,7 @@ static int f2fs_write_root_inode(void)
 			c.blks_per_seg, main_area_node_seg_blk_offset);
 	if (dev_write_block(raw_node, main_area_node_seg_blk_offset)) {
 		MSG(1, "\tError: While writing the raw_node to disk!!!\n");
+		free(raw_node);
 		return -1;
 	}
 
@@ -1052,9 +1053,11 @@ static int f2fs_write_root_inode(void)
 
 #ifndef WITH_ANDROID
 	if (discard_obsolete_dnode(raw_node, main_area_node_seg_blk_offset)) {
+		free(raw_node);
 		return -1;
 	}
 #endif
+	free(raw_node);
 	return 0;
 }
 
-- 
2.15.0.55.gc2ece9dc4de6


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] f2fs-tools: adjust feature name
  2017-11-16 11:50 ` Chao Yu
@ 2017-11-16 11:50   ` Chao Yu
  -1 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

This patch slightly changes showed feature name.

Before:
Info: superblock features = f9 :  encrypt extra attribute project quota inode checksum flexible inline xattr quota ino

After:
Info: superblock features = f9 :  encrypt extra_attr project_quota inode_checksum flexible_inline_xattr quota_ino

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/mount.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index c094f940ee1b..4ad22a136ca9 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -429,22 +429,22 @@ void print_sb_state(struct f2fs_super_block *sb)
 		MSG(0, "%s", " encrypt");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_BLKZONED)) {
-		MSG(0, "%s", " zoned block device");
+		MSG(0, "%s", " blkzoned");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
-		MSG(0, "%s", " extra attribute");
+		MSG(0, "%s", " extra_attr");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) {
-		MSG(0, "%s", " project quota");
+		MSG(0, "%s", " project_quota");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM)) {
-		MSG(0, "%s", " inode checksum");
+		MSG(0, "%s", " inode_checksum");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_FLEXIBLE_INLINE_XATTR)) {
-		MSG(0, "%s", " flexible inline xattr");
+		MSG(0, "%s", " flexible_inline_xattr");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) {
-		MSG(0, "%s", " quota ino");
+		MSG(0, "%s", " quota_ino");
 	}
 	MSG(0, "\n");
 	MSG(0, "Info: superblock encrypt level = %d, salt = ",
-- 
2.15.0.55.gc2ece9dc4de6

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] f2fs-tools: adjust feature name
@ 2017-11-16 11:50   ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2017-11-16 11:50 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

This patch slightly changes showed feature name.

Before:
Info: superblock features = f9 :  encrypt extra attribute project quota inode checksum flexible inline xattr quota ino

After:
Info: superblock features = f9 :  encrypt extra_attr project_quota inode_checksum flexible_inline_xattr quota_ino

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/mount.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index c094f940ee1b..4ad22a136ca9 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -429,22 +429,22 @@ void print_sb_state(struct f2fs_super_block *sb)
 		MSG(0, "%s", " encrypt");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_BLKZONED)) {
-		MSG(0, "%s", " zoned block device");
+		MSG(0, "%s", " blkzoned");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_EXTRA_ATTR)) {
-		MSG(0, "%s", " extra attribute");
+		MSG(0, "%s", " extra_attr");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) {
-		MSG(0, "%s", " project quota");
+		MSG(0, "%s", " project_quota");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM)) {
-		MSG(0, "%s", " inode checksum");
+		MSG(0, "%s", " inode_checksum");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_FLEXIBLE_INLINE_XATTR)) {
-		MSG(0, "%s", " flexible inline xattr");
+		MSG(0, "%s", " flexible_inline_xattr");
 	}
 	if (f & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) {
-		MSG(0, "%s", " quota ino");
+		MSG(0, "%s", " quota_ino");
 	}
 	MSG(0, "\n");
 	MSG(0, "Info: superblock encrypt level = %d, salt = ",
-- 
2.15.0.55.gc2ece9dc4de6


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-11-16 11:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16 11:50 [PATCH 1/4] dump.f2fs: show extra attr only when feature is enabled Chao Yu
2017-11-16 11:50 ` Chao Yu
2017-11-16 11:50 ` [PATCH 2/4] fsck.f2fs: fix potential stack overflow issue Chao Yu
2017-11-16 11:50   ` Chao Yu
2017-11-16 11:50 ` [PATCH 3/4] f2fs: avoid memory leak in f2fs_write_root_inode Chao Yu
2017-11-16 11:50   ` Chao Yu
2017-11-16 11:50 ` [PATCH 4/4] f2fs-tools: adjust feature name Chao Yu
2017-11-16 11:50   ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.