NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/60053: [PATCH] fsck_ext2fs: add sanity check for EXT2_HUGE_FILE without HUGE_FILE feature
>Number: 60053
>Category: kern
>Synopsis: [PATCH] fsck_ext2fs: add sanity check for EXT2_HUGE_FILE without HUGE_FILE feature
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Mar 03 21:35:01 +0000 2026
>Originator: ssszcmawo
>Release: 11.95.5
>Organization:
>Environment:
n/a
>Description:
Add consistency check in inonblock(): reject inodes that have the
EXT2_HUGE_FILE flag set without the corresponding EXT2F_ROCOMPAT_HUGE_FILE
feature in the superblock. Previously such inconsistency was silently
accepted. Also added a warning when directory entry names are truncated due to length > MAXPATHLEN.
>How-To-Repeat:
>Fix:
>From defc50de65403e684597ffd22389055eaa35cbdd Mon Sep 17 00:00:00 2001
From: ssszcmawo <belan2470%gmail.com@localhost>
Date: Tue, 3 Mar 2026 15:29:53 +0100
Subject: [PATCH] add additional check for huge files and comments
---
sbin/fsck_ext2fs/inode.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/sbin/fsck_ext2fs/inode.c b/sbin/fsck_ext2fs/inode.c
index 97f02b84a..c12857d5b 100644
--- a/sbin/fsck_ext2fs/inode.c
+++ b/sbin/fsck_ext2fs/inode.c
@@ -600,7 +600,8 @@ findname(struct inodesc *idesc)
/* from utilities.c namebuf[] variable */
char *buf = __UNCONST(idesc->id_name);
if (namlen > MAXPATHLEN) {
- /* XXX: Prevent overflow but don't fix */
+ /* XXX: Prevent overflow but don't fix */
+ printf("entry name truncated");
namlen = MAXPATHLEN;
}
@@ -755,25 +756,34 @@ freeino(ino_t ino)
n_files--;
}
+/*
+ * read the number of block from inode
+ */
uint64_t
inonblock(struct ext2fs_dinode *dp)
{
uint64_t nblock;
-
- /* XXX check for EXT2_HUGE_FILE without EXT2F_ROCOMPAT_HUGE_FILE? */
+ uint32_t flags;
nblock = fs2h32(dp->e2di_nblock);
+ flags = fs2h32(dp->e2di_flags);
- if ((sblock.e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_HUGE_FILE)) {
- nblock |= (uint64_t)fs2h16(dp->e2di_nblock_high) << 32;
- if (fs2h32(dp->e2di_flags) & EXT2_HUGE_FILE) {
- nblock = EXT2_FSBTODB(&sblock, nblock);
- }
+ if ((flags & EXT2_HUGE_FILE) &&
+ !(sblock.e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_HUGE_FILE)) {
+ pfatal("inconsistent filesystem");
}
+ if (sblock.e2fs.e2fs_features_rocompat & EXT2F_ROCOMPAT_HUGE_FILE)
+ nblock |= (uint64_t)fs2h16(dp->e2di_nblock_high) << 32;
+
+ if (flags & EXT2_HUGE_FILE)
+ nblock = EXT2_FSBTODB(&sblock, nblock);
return nblock;
}
+/*
+ * set the number of block in an inode
+ */
void
inosnblock(struct ext2fs_dinode *dp, uint64_t nblock)
{
--
2.47.3
Home |
Main Index |
Thread Index |
Old Index