f2fs: add sanity check for quota sysfile ino
PATCH 1/1 f2fs: add sanity check for quota sysfile ino
Add missing sanity check for quota sysfile ino.
--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
fs/f2fs/super.c +19 -0
@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",
Signature · 6 lines
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
Jaegeuk Kim
maintainerQuoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
Quoted 38 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6
Quoted 6 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
Do you mean:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) {
if (!le32_to_cpu(raw_super->qf_ino[0]) ||
!le32_to_cpu(raw_super->qf_ino[1])) {
f2fs_msg(sb, KERN_INFO,
"Invalid Quota Ino: user_ino(%u), grp_ino(%u)",
le32_to_cpu(raw_super->qf_ino[0]),
le32_to_cpu(raw_super->qf_ino[1]));
return 1;
}
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) &&
!le32_to_cpu(raw_super->qf_ino[2])) {
f2fs_msg(sb, KERN_INFO,
"Invalid Quota Ino: prj_ino(%u)",
le32_to_cpu(raw_super->qf_ino[2]));
return 1;
}
}I think it's equal to:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) {
unsigned int qf_cnt = 0;
if (qf_ino[0])
qf_cnt++;
if (qf_ino[1])
qf_cnt++;
if (qf_cnt != 2) {
f2fs_msg();
return 1;
}
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) {
if (qf_ino[2])
qf_cnt++;
if (qf_cnt != 3) {
f2fs_msg();
return 1;
}
}
}Thanks,
Quoted 42 lines
Quoted 39 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Jaegeuk Kim
maintainerQuoted 7 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
If quota_ino is set, f2fs_enable_quotas() will be failed, if its ino is invalid. It'd be also fine, if we have no inode numbers there. What I mean was we may need to consider reallocating or deallocating inode numbers later.
Quoted 87 lines
Do you mean:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { if (!le32_to_cpu(raw_super->qf_ino[0]) || !le32_to_cpu(raw_super->qf_ino[1])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: user_ino(%u), grp_ino(%u)", le32_to_cpu(raw_super->qf_ino[0]), le32_to_cpu(raw_super->qf_ino[1])); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) && !le32_to_cpu(raw_super->qf_ino[2])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: prj_ino(%u)", le32_to_cpu(raw_super->qf_ino[2])); return 1; } }I think it's equal to:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { unsigned int qf_cnt = 0; if (qf_ino[0]) qf_cnt++; if (qf_ino[1]) qf_cnt++; if (qf_cnt != 2) { f2fs_msg(); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) { if (qf_ino[2]) qf_cnt++; if (qf_cnt != 3) { f2fs_msg(); return 1; } } }Thanks,
Quoted 42 lines
Quoted 39 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
If
quota_inois set,f2fs_enable_quotas()will be failed, if its ino is invalid. It'd be also fine, if we have no inode numbers there. What I mean was we may need to consider reallocating or deallocating inode numbers later.
Oh, so that it will be better to do more check & repair in fsck tools, right?
Thanks,
Quoted 91 lines
Quoted 44 lines
Do you mean:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { if (!le32_to_cpu(raw_super->qf_ino[0]) || !le32_to_cpu(raw_super->qf_ino[1])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: user_ino(%u), grp_ino(%u)", le32_to_cpu(raw_super->qf_ino[0]), le32_to_cpu(raw_super->qf_ino[1])); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) && !le32_to_cpu(raw_super->qf_ino[2])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: prj_ino(%u)", le32_to_cpu(raw_super->qf_ino[2])); return 1; } }I think it's equal to:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { unsigned int qf_cnt = 0; if (qf_ino[0]) qf_cnt++; if (qf_ino[1]) qf_cnt++; if (qf_cnt != 2) { f2fs_msg(); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) { if (qf_ino[2]) qf_cnt++; if (qf_cnt != 3) { f2fs_msg(); return 1; } } }Quoted 44 lines
Thanks,
Quoted 42 lines
Quoted 39 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
Jaegeuk Kim
maintainerQuoted 10 lines · Chao Yu
Quoted 9 lines · Jaegeuk Kim
Quoted 7 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
Quoted 5 lines
Quoted 3 lines
If
quota_inois set,f2fs_enable_quotas()will be failed, if its ino is invalid. It'd be also fine, if we have no inode numbers there. What I mean was we may need to consider reallocating or deallocating inode numbers later.Oh, so that it will be better to do more check & repair in fsck tools, right?
What is the rule that you're considering? We're already checking quota inodes in fsck.f2fs.
Quoted 94 lines
Thanks,
Quoted 91 lines
Quoted 44 lines
Do you mean:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { if (!le32_to_cpu(raw_super->qf_ino[0]) || !le32_to_cpu(raw_super->qf_ino[1])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: user_ino(%u), grp_ino(%u)", le32_to_cpu(raw_super->qf_ino[0]), le32_to_cpu(raw_super->qf_ino[1])); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) && !le32_to_cpu(raw_super->qf_ino[2])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: prj_ino(%u)", le32_to_cpu(raw_super->qf_ino[2])); return 1; } }I think it's equal to:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { unsigned int qf_cnt = 0; if (qf_ino[0]) qf_cnt++; if (qf_ino[1]) qf_cnt++; if (qf_cnt != 2) { f2fs_msg(); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) { if (qf_ino[2]) qf_cnt++; if (qf_cnt != 3) { f2fs_msg(); return 1; } } }Quoted 44 lines
Thanks,
Quoted 42 lines
Quoted 39 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
Quoted 11 lines · Jaegeuk Kim
Quoted 10 lines · Chao Yu
Quoted 9 lines · Jaegeuk Kim
Quoted 7 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
If
quota_inois set,f2fs_enable_quotas()will be failed, if its ino is invalid. It'd be also fine, if we have no inode numbers there. What I mean was we may need to consider reallocating or deallocating inode numbers later.Oh, so that it will be better to do more check & repair in fsck tools, right?
What is the rule that you're considering? We're already checking quota inodes in fsck.f2fs.
The case that qf_ino[] is corrupted, I didn't see it can be relinked to corresponding quota inode by fsck, am I missing something?
Thanks,
Quoted 98 lines
Quoted 95 lines
Thanks,
Quoted 91 lines
Quoted 44 lines
Do you mean:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { if (!le32_to_cpu(raw_super->qf_ino[0]) || !le32_to_cpu(raw_super->qf_ino[1])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: user_ino(%u), grp_ino(%u)", le32_to_cpu(raw_super->qf_ino[0]), le32_to_cpu(raw_super->qf_ino[1])); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) && !le32_to_cpu(raw_super->qf_ino[2])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: prj_ino(%u)", le32_to_cpu(raw_super->qf_ino[2])); return 1; } }I think it's equal to:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { unsigned int qf_cnt = 0; if (qf_ino[0]) qf_cnt++; if (qf_ino[1]) qf_cnt++; if (qf_cnt != 2) { f2fs_msg(); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) { if (qf_ino[2]) qf_cnt++; if (qf_cnt != 3) { f2fs_msg(); return 1; } } }Quoted 44 lines
Thanks,
Quoted 42 lines
Quoted 39 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
.
Jaegeuk Kim
maintainerQuoted 16 lines · Chao Yu
Quoted 15 lines · Jaegeuk Kim
Quoted 14 lines · Chao Yu
Quoted 12 lines · Jaegeuk Kim
Quoted 7 lines · Chao Yu
Quoted 6 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
If
quota_inois set,f2fs_enable_quotas()will be failed, if its ino is invalid. It'd be also fine, if we have no inode numbers there. What I mean was we may need to consider reallocating or deallocating inode numbers later.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Oh, so that it will be better to do more check & repair in fsck tools, right?
What is the rule that you're considering? We're already checking quota inodes in fsck.f2fs.
The case that qf_ino[] is corrupted, I didn't see it can be relinked to corresponding quota inode by fsck, am I missing something?
We can check its basic metadata such as i_mode? Or, in order to do that entirely, we need to add file truncation and creationg in fsck.f2fs, which was too complicated to add before.
Any idea?
Thanks,
Quoted 101 lines
Thanks,
Quoted 98 lines
Quoted 95 lines
Thanks,
Quoted 91 lines
Quoted 44 lines
Do you mean:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { if (!le32_to_cpu(raw_super->qf_ino[0]) || !le32_to_cpu(raw_super->qf_ino[1])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: user_ino(%u), grp_ino(%u)", le32_to_cpu(raw_super->qf_ino[0]), le32_to_cpu(raw_super->qf_ino[1])); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) && !le32_to_cpu(raw_super->qf_ino[2])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: prj_ino(%u)", le32_to_cpu(raw_super->qf_ino[2])); return 1; } }I think it's equal to:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { unsigned int qf_cnt = 0; if (qf_ino[0]) qf_cnt++; if (qf_ino[1]) qf_cnt++; if (qf_cnt != 2) { f2fs_msg(); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) { if (qf_ino[2]) qf_cnt++; if (qf_cnt != 3) { f2fs_msg(); return 1; } } }Quoted 44 lines
Thanks,
Quoted 42 lines
Quoted 39 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
.
Chao Yu
maintainerQuoted 19 lines · Jaegeuk Kim
Quoted 18 lines · Chao Yu
Quoted 17 lines · Jaegeuk Kim
Quoted 15 lines · Chao Yu
Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Quoted 1 line · Chao Yu
Add missing sanity check for quota sysfile ino.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
We don't need to limit the specific inode numbers for quota files, since we may be able to set any inode numbers later. How about checkint the numbers are allocated as quota?
If
quota_inois set,f2fs_enable_quotas()will be failed, if its ino is invalid. It'd be also fine, if we have no inode numbers there. What I mean was we may need to consider reallocating or deallocating inode numbers later.Oh, so that it will be better to do more check & repair in fsck tools, right?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
What is the rule that you're considering? We're already checking quota inodes in fsck.f2fs.
The case that qf_ino[] is corrupted, I didn't see it can be relinked to corresponding quota inode by fsck, am I missing something?
We can check its basic metadata such as
i_mode? Or, in order to do that
Agreed, how about:
if (i_mode == 0x8180 && i_flags == FS_IMMUTABLE_FL &&
i_name[0] == 0x00 && i_namelen == 0) relink super_block::qf_ino to quote inode;
Quoted 1 line
entirely, we need to add file truncation and creationg in fsck.f2fs, which
Yes, I think we can rebuild sys quote file if original one is missing or corrupted.
Thanks,
Quoted 106 lines
was too complicated to add before.
Any idea?Thanks,
Quoted 101 lines
Thanks,
Quoted 98 lines
Quoted 95 lines
Thanks,
Quoted 91 lines
Quoted 44 lines
Do you mean:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { if (!le32_to_cpu(raw_super->qf_ino[0]) || !le32_to_cpu(raw_super->qf_ino[1])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: user_ino(%u), grp_ino(%u)", le32_to_cpu(raw_super->qf_ino[0]), le32_to_cpu(raw_super->qf_ino[1])); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) && !le32_to_cpu(raw_super->qf_ino[2])) { f2fs_msg(sb, KERN_INFO, "Invalid Quota Ino: prj_ino(%u)", le32_to_cpu(raw_super->qf_ino[2])); return 1; } }I think it's equal to:
if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { unsigned int qf_cnt = 0; if (qf_ino[0]) qf_cnt++; if (qf_ino[1]) qf_cnt++; if (qf_cnt != 2) { f2fs_msg(); return 1; } if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA)) { if (qf_ino[2]) qf_cnt++; if (qf_cnt != 3) { f2fs_msg(); return 1; } } }Quoted 44 lines
Thanks,
Quoted 42 lines
Quoted 39 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)fs/f2fs/super.c +19
-0@@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,return 1 ; } +/* check quota sysfile ino info */ +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_QUOTA_INO )) { +if (le32_to_cpu (raw_super->qf_ino[0 ]) !=4 || +le32_to_cpu (raw_super->qf_ino[1 ]) !=5 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: user_ino(%u), grp_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[0 ]), +le32_to_cpu (raw_super->qf_ino[1 ])); +return 1 ; + } +if (raw_super->feature &cpu_to_le32 (F2FS_FEATURE_PRJQUOTA ) && +le32_to_cpu (raw_super->qf_ino[2 ]) !=6 ) { +f2fs_msg (sb,KERN_INFO , +"Invalid Quota Ino: prj_ino(%u)" , +le32_to_cpu (raw_super->qf_ino[2 ])); +return 1 ; + } + } +if (le32_to_cpu (raw_super->segment_count) >F2FS_MAX_SEGMENT ) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)",Signature · 1 line
2.15.0.55.gc2ece9dc4de6.
.
.