* [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g
@ 2022-11-10 14:07 Sheng Yong via Linux-f2fs-devel
2022-11-10 14:07 ` [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK Sheng Yong via Linux-f2fs-devel
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Sheng Yong via Linux-f2fs-devel @ 2022-11-10 14:07 UTC (permalink / raw)
To: chao, jaegeuk; +Cc: linux-f2fs-devel
Option "-g" for dump.f2fs is unavailable and not used in dump.f2fs.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
fsck/main.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/fsck/main.c b/fsck/main.c
index 3268664..9b50787 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -273,8 +273,10 @@ void f2fs_parse_options(int argc, char *argv[])
atoi(optarg);
break;
case 'g':
- if (!strcmp(optarg, "android"))
+ if (!strcmp(optarg, "android")) {
c.defset = CONF_ANDROID;
+ MSG(0, "Info: Set conf for android\n");
+ }
break;
case 'l':
c.layout = 1;
@@ -409,14 +411,6 @@ void f2fs_parse_options(int argc, char *argv[])
MSG(0, "Info: Debug level = %d\n",
c.dbg_lv);
break;
- case 'g':
- if (!strcmp(optarg, "android")) {
- c.defset = CONF_ANDROID;
- MSG(0, "Info: Set conf for android\n");
- break;
- }
- err = EWRONG_OPT;
- break;
case 'i':
if (strncmp(optarg, "0x", 2))
ret = sscanf(optarg, "%d",
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK
2022-11-10 14:07 [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g Sheng Yong via Linux-f2fs-devel
@ 2022-11-10 14:07 ` Sheng Yong via Linux-f2fs-devel
2022-11-14 7:10 ` Chao Yu
2022-11-10 14:07 ` [f2fs-dev] [PATCH 3/4] fsck.f2fs: fix potential overflow of copying i_name Sheng Yong via Linux-f2fs-devel
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Sheng Yong via Linux-f2fs-devel @ 2022-11-10 14:07 UTC (permalink / raw)
To: chao, jaegeuk; +Cc: linux-f2fs-devel
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
fsck/fsck.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fsck/fsck.h b/fsck/fsck.h
index 939450f..dabd8b9 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -50,7 +50,7 @@ enum SB_ADDR {
SB_MAX_ADDR,
};
-#define SB_MASK(i) (1 << i)
+#define SB_MASK(i) (1 << (i))
#define SB_MASK_ALL (SB_MASK(SB0_ADDR) | SB_MASK(SB1_ADDR))
/* fsck.c */
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [f2fs-dev] [PATCH 3/4] fsck.f2fs: fix potential overflow of copying i_name
2022-11-10 14:07 [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g Sheng Yong via Linux-f2fs-devel
2022-11-10 14:07 ` [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK Sheng Yong via Linux-f2fs-devel
@ 2022-11-10 14:07 ` Sheng Yong via Linux-f2fs-devel
2022-11-14 7:14 ` Chao Yu
2022-11-10 14:07 ` [f2fs-dev] [PATCH 4/4] fsck.f2fs: avoid uncessary recalculation Sheng Yong via Linux-f2fs-devel
2022-11-14 7:10 ` [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g Chao Yu
3 siblings, 1 reply; 10+ messages in thread
From: Sheng Yong via Linux-f2fs-devel @ 2022-11-10 14:07 UTC (permalink / raw)
To: chao, jaegeuk; +Cc: linux-f2fs-devel
If i_namelen is corrupted, there may be an overflow when doing memcpy.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
fsck/fsck.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 036a834..ebc60ad 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -742,8 +742,10 @@ check_next:
if (ftype == F2FS_FT_DIR) {
f2fs_set_main_bitmap(sbi, ni->blk_addr, CURSEG_HOT_NODE);
- memcpy(child.p_name, node_blk->i.i_name,
- node_blk->i.i_namelen);
+ namelen = le32_to_cpu(node_blk->i.i_namelen);
+ if (namelen > F2FS_NAME_LEN)
+ namelen = F2FS_NAME_LEN;
+ memcpy(child.p_name, node_blk->i.i_name, namelen);
} else {
if (f2fs_test_main_bitmap(sbi, ni->blk_addr) == 0) {
f2fs_set_main_bitmap(sbi, ni->blk_addr,
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [f2fs-dev] [PATCH 4/4] fsck.f2fs: avoid uncessary recalculation
2022-11-10 14:07 [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g Sheng Yong via Linux-f2fs-devel
2022-11-10 14:07 ` [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK Sheng Yong via Linux-f2fs-devel
2022-11-10 14:07 ` [f2fs-dev] [PATCH 3/4] fsck.f2fs: fix potential overflow of copying i_name Sheng Yong via Linux-f2fs-devel
@ 2022-11-10 14:07 ` Sheng Yong via Linux-f2fs-devel
2022-11-14 7:29 ` Chao Yu
2022-11-14 7:10 ` [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g Chao Yu
3 siblings, 1 reply; 10+ messages in thread
From: Sheng Yong via Linux-f2fs-devel @ 2022-11-10 14:07 UTC (permalink / raw)
To: chao, jaegeuk; +Cc: linux-f2fs-devel
There is no need to recalculate ADDRS_PER_INODE and ADDRS_PER_BLOCK,
especially in a for loop.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
fsck/fsck.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/fsck/fsck.c b/fsck/fsck.c
index ebc60ad..ec096f2 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -706,7 +706,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
int ofs;
char *en;
u32 namelen;
- unsigned int idx = 0;
+ unsigned int addrs, idx = 0;
unsigned short i_gc_failures;
int need_fix = 0;
int ret;
@@ -932,17 +932,16 @@ check_next:
}
/* check data blocks in inode */
+ addrs = ADDRS_PER_INODE(&node_blk->i);
if (cur_qtype != -1) {
+ unsigned int addrs_per_blk = ADDRS_PER_BLOCK(&node_blk->i);
qf_szchk_type[cur_qtype] = QF_SZCHK_REGFILE;
- qf_maxsize[cur_qtype] = (ADDRS_PER_INODE(&node_blk->i) +
- 2 * ADDRS_PER_BLOCK(&node_blk->i) +
- 2 * ADDRS_PER_BLOCK(&node_blk->i) *
- NIDS_PER_BLOCK +
- (u64) ADDRS_PER_BLOCK(&node_blk->i) *
- NIDS_PER_BLOCK * NIDS_PER_BLOCK) * F2FS_BLKSIZE;
- }
- for (idx = 0; idx < ADDRS_PER_INODE(&node_blk->i);
- idx++, child.pgofs++) {
+ qf_maxsize[cur_qtype] = (addrs + 2 * addrs_per_blk +
+ 2 * addrs_per_blk * NIDS_PER_BLOCK +
+ (u64) addrs_per_blk * NIDS_PER_BLOCK *
+ NIDS_PER_BLOCK) * F2FS_BLKSIZE;
+ }
+ for (idx = 0; idx < addrs; idx++, child.pgofs++) {
block_t blkaddr = le32_to_cpu(node_blk->i.i_addr[ofs + idx]);
/* check extent info */
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g
2022-11-10 14:07 [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g Sheng Yong via Linux-f2fs-devel
` (2 preceding siblings ...)
2022-11-10 14:07 ` [f2fs-dev] [PATCH 4/4] fsck.f2fs: avoid uncessary recalculation Sheng Yong via Linux-f2fs-devel
@ 2022-11-14 7:10 ` Chao Yu
3 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2022-11-14 7:10 UTC (permalink / raw)
To: Sheng Yong, jaegeuk; +Cc: linux-f2fs-devel
On 2022/11/10 22:07, Sheng Yong wrote:
> Option "-g" for dump.f2fs is unavailable and not used in dump.f2fs.
>
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK
2022-11-10 14:07 ` [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK Sheng Yong via Linux-f2fs-devel
@ 2022-11-14 7:10 ` Chao Yu
0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2022-11-14 7:10 UTC (permalink / raw)
To: Sheng Yong, jaegeuk; +Cc: linux-f2fs-devel
On 2022/11/10 22:07, Sheng Yong wrote:
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH 3/4] fsck.f2fs: fix potential overflow of copying i_name
2022-11-10 14:07 ` [f2fs-dev] [PATCH 3/4] fsck.f2fs: fix potential overflow of copying i_name Sheng Yong via Linux-f2fs-devel
@ 2022-11-14 7:14 ` Chao Yu
0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2022-11-14 7:14 UTC (permalink / raw)
To: Sheng Yong, jaegeuk; +Cc: linux-f2fs-devel
On 2022/11/10 22:07, Sheng Yong wrote:
> If i_namelen is corrupted, there may be an overflow when doing memcpy.
>
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH 4/4] fsck.f2fs: avoid uncessary recalculation
2022-11-10 14:07 ` [f2fs-dev] [PATCH 4/4] fsck.f2fs: avoid uncessary recalculation Sheng Yong via Linux-f2fs-devel
@ 2022-11-14 7:29 ` Chao Yu
2022-11-14 14:17 ` [f2fs-dev] [PATCH v2] " Sheng Yong via Linux-f2fs-devel
0 siblings, 1 reply; 10+ messages in thread
From: Chao Yu @ 2022-11-14 7:29 UTC (permalink / raw)
To: Sheng Yong, jaegeuk; +Cc: linux-f2fs-devel
On 2022/11/10 22:07, Sheng Yong wrote:
> There is no need to recalculate ADDRS_PER_INODE and ADDRS_PER_BLOCK,
> especially in a for loop.
>
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
> ---
> fsck/fsck.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/fsck/fsck.c b/fsck/fsck.c
> index ebc60ad..ec096f2 100644
> --- a/fsck/fsck.c
> +++ b/fsck/fsck.c
> @@ -706,7 +706,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
> int ofs;
> char *en;
> u32 namelen;
> - unsigned int idx = 0;
> + unsigned int addrs, idx = 0;
> unsigned short i_gc_failures;
> int need_fix = 0;
> int ret;
> @@ -932,17 +932,16 @@ check_next:
> }
>
> /* check data blocks in inode */
> + addrs = ADDRS_PER_INODE(&node_blk->i);
> if (cur_qtype != -1) {
> + unsigned int addrs_per_blk = ADDRS_PER_BLOCK(&node_blk->i);
> qf_szchk_type[cur_qtype] = QF_SZCHK_REGFILE;
> - qf_maxsize[cur_qtype] = (ADDRS_PER_INODE(&node_blk->i) +
> - 2 * ADDRS_PER_BLOCK(&node_blk->i) +
> - 2 * ADDRS_PER_BLOCK(&node_blk->i) *
> - NIDS_PER_BLOCK +
> - (u64) ADDRS_PER_BLOCK(&node_blk->i) *
> - NIDS_PER_BLOCK * NIDS_PER_BLOCK) * F2FS_BLKSIZE;
> - }
> - for (idx = 0; idx < ADDRS_PER_INODE(&node_blk->i);
> - idx++, child.pgofs++) {
> + qf_maxsize[cur_qtype] = (addrs + 2 * addrs_per_blk +
u64(addrs + 2 * addrs_per_blk +
Otherwise, the result may overflow...
Thanks,
> + 2 * addrs_per_blk * NIDS_PER_BLOCK +
> + (u64) addrs_per_blk * NIDS_PER_BLOCK *
> + NIDS_PER_BLOCK) * F2FS_BLKSIZE;
> + }
> + for (idx = 0; idx < addrs; idx++, child.pgofs++) {
> block_t blkaddr = le32_to_cpu(node_blk->i.i_addr[ofs + idx]);
>
> /* check extent info */
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [f2fs-dev] [PATCH v2] fsck.f2fs: avoid uncessary recalculation
2022-11-14 7:29 ` Chao Yu
@ 2022-11-14 14:17 ` Sheng Yong via Linux-f2fs-devel
2022-11-14 14:59 ` Chao Yu
0 siblings, 1 reply; 10+ messages in thread
From: Sheng Yong via Linux-f2fs-devel @ 2022-11-14 14:17 UTC (permalink / raw)
To: chao; +Cc: jaegeuk, linux-f2fs-devel
There is no need to recalculate ADDRS_PER_INODE and ADDRS_PER_BLOCK,
especially in a for loop.
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
fsck/fsck.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/fsck/fsck.c b/fsck/fsck.c
index ebc60ad..df91c82 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -706,7 +706,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
int ofs;
char *en;
u32 namelen;
- unsigned int idx = 0;
+ unsigned int addrs, idx = 0;
unsigned short i_gc_failures;
int need_fix = 0;
int ret;
@@ -932,17 +932,16 @@ check_next:
}
/* check data blocks in inode */
+ addrs = ADDRS_PER_INODE(&node_blk->i);
if (cur_qtype != -1) {
+ u64 addrs_per_blk = (u64)ADDRS_PER_BLOCK(&node_blk->i);
qf_szchk_type[cur_qtype] = QF_SZCHK_REGFILE;
- qf_maxsize[cur_qtype] = (ADDRS_PER_INODE(&node_blk->i) +
- 2 * ADDRS_PER_BLOCK(&node_blk->i) +
- 2 * ADDRS_PER_BLOCK(&node_blk->i) *
- NIDS_PER_BLOCK +
- (u64) ADDRS_PER_BLOCK(&node_blk->i) *
- NIDS_PER_BLOCK * NIDS_PER_BLOCK) * F2FS_BLKSIZE;
- }
- for (idx = 0; idx < ADDRS_PER_INODE(&node_blk->i);
- idx++, child.pgofs++) {
+ qf_maxsize[cur_qtype] = (u64)(addrs + 2 * addrs_per_blk +
+ 2 * addrs_per_blk * NIDS_PER_BLOCK +
+ addrs_per_blk * NIDS_PER_BLOCK *
+ NIDS_PER_BLOCK) * F2FS_BLKSIZE;
+ }
+ for (idx = 0; idx < addrs; idx++, child.pgofs++) {
block_t blkaddr = le32_to_cpu(node_blk->i.i_addr[ofs + idx]);
/* check extent info */
--
2.25.1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH v2] fsck.f2fs: avoid uncessary recalculation
2022-11-14 14:17 ` [f2fs-dev] [PATCH v2] " Sheng Yong via Linux-f2fs-devel
@ 2022-11-14 14:59 ` Chao Yu
0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2022-11-14 14:59 UTC (permalink / raw)
To: Sheng Yong; +Cc: jaegeuk, linux-f2fs-devel
On 2022/11/14 22:17, Sheng Yong wrote:
> There is no need to recalculate ADDRS_PER_INODE and ADDRS_PER_BLOCK,
> especially in a for loop.
>
> Signed-off-by: Sheng Yong <shengyong@oppo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-11-14 15:00 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-10 14:07 [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g Sheng Yong via Linux-f2fs-devel
2022-11-10 14:07 ` [f2fs-dev] [PATCH 2/4] fsck.f2fs: add parentheses for SB_MASK Sheng Yong via Linux-f2fs-devel
2022-11-14 7:10 ` Chao Yu
2022-11-10 14:07 ` [f2fs-dev] [PATCH 3/4] fsck.f2fs: fix potential overflow of copying i_name Sheng Yong via Linux-f2fs-devel
2022-11-14 7:14 ` Chao Yu
2022-11-10 14:07 ` [f2fs-dev] [PATCH 4/4] fsck.f2fs: avoid uncessary recalculation Sheng Yong via Linux-f2fs-devel
2022-11-14 7:29 ` Chao Yu
2022-11-14 14:17 ` [f2fs-dev] [PATCH v2] " Sheng Yong via Linux-f2fs-devel
2022-11-14 14:59 ` Chao Yu
2022-11-14 7:10 ` [f2fs-dev] [PATCH 1/4] dump.f2fs: remove unavailable optiont -g 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.