Compare commits
10 Commits
9f4880b547
...
82e4113f7d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82e4113f7d | ||
|
|
f34a9635c9 | ||
|
|
46336b8de1 | ||
|
|
1d8a9f90df | ||
|
|
9779ca6902 | ||
|
|
123acfedcf | ||
|
|
727f634059 | ||
|
|
f920f49010 | ||
|
|
0e8345d1c8 | ||
|
|
8ee7a34400 |
70
0041-debugfs-Fix-infinite-loop-when-dump-log.patch
Normal file
70
0041-debugfs-Fix-infinite-loop-when-dump-log.patch
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
From a1530ed61778e99da315cb10cea2c46d215b096f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Wenchao Hao <haowenchao2@huawei.com>
|
||||||
|
Date: Tue, 19 Dec 2023 17:23:57 +0800
|
||||||
|
Subject: [PATCH] debugfs: Fix infinite loop when dump log
|
||||||
|
|
||||||
|
There are 2 scenarios which would trigger infinite loop:
|
||||||
|
|
||||||
|
1. None log is recorded, then dumplog with "-n", for example:
|
||||||
|
debugfs -R "logdump -O -n 10" /dev/xxx
|
||||||
|
while /dev/xxx has no valid log recorded.
|
||||||
|
2. The log area is full and cycle write is triggered, then dumplog with
|
||||||
|
debugfs -R "logdump -aOS" /dev/xxx
|
||||||
|
|
||||||
|
This patch add a new flag "reverse_flag" to mark if logdump has reached
|
||||||
|
to tail of logarea, it is default false, and set in macro WRAP().
|
||||||
|
|
||||||
|
If reverse_flag is true, and we comes to first_transaction_blocknr
|
||||||
|
again, just break the logdump loop.
|
||||||
|
|
||||||
|
Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
|
||||||
|
---
|
||||||
|
debugfs/logdump.c | 11 +++++++----
|
||||||
|
1 file changed, 7 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
|
||||||
|
index 853be41..c4686ae 100644
|
||||||
|
--- a/debugfs/logdump.c
|
||||||
|
+++ b/debugfs/logdump.c
|
||||||
|
@@ -45,6 +45,7 @@ static int64_t dump_counts;
|
||||||
|
static blk64_t block_to_dump, bitmap_to_dump, inode_block_to_dump;
|
||||||
|
static unsigned int group_to_dump, inode_offset_to_dump;
|
||||||
|
static ext2_ino_t inode_to_dump;
|
||||||
|
+static bool reverse_flag;
|
||||||
|
|
||||||
|
struct journal_source
|
||||||
|
{
|
||||||
|
@@ -73,8 +74,10 @@ static void dump_fc_block(FILE *out_file, char *buf, int blocksize,
|
||||||
|
static void do_hexdump (FILE *, char *, int);
|
||||||
|
|
||||||
|
#define WRAP(jsb, blocknr, maxlen) \
|
||||||
|
- if (blocknr >= (maxlen)) \
|
||||||
|
- blocknr -= (maxlen - be32_to_cpu((jsb)->s_first));
|
||||||
|
+ if (blocknr >= (maxlen)) { \
|
||||||
|
+ blocknr -= (maxlen - be32_to_cpu((jsb)->s_first)); \
|
||||||
|
+ reverse_flag = true; \
|
||||||
|
+ }
|
||||||
|
|
||||||
|
void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
|
||||||
|
void *infop EXT2FS_ATTR((unused)))
|
||||||
|
@@ -108,6 +111,7 @@ void do_logdump(int argc, char **argv, int sci_idx EXT2FS_ATTR((unused)),
|
||||||
|
inode_block_to_dump = ANY_BLOCK;
|
||||||
|
inode_to_dump = -1;
|
||||||
|
dump_counts = -1;
|
||||||
|
+ reverse_flag = false;
|
||||||
|
|
||||||
|
reset_getopt();
|
||||||
|
while ((c = getopt (argc, argv, "ab:ci:f:OsSn:")) != EOF) {
|
||||||
|
@@ -470,8 +474,7 @@ static void dump_journal(char *cmdname, FILE *out_file,
|
||||||
|
if (dump_old && (dump_counts != -1) && (cur_counts >= dump_counts))
|
||||||
|
break;
|
||||||
|
|
||||||
|
- if ((blocknr == first_transaction_blocknr) &&
|
||||||
|
- (cur_counts != 0) && dump_old && (dump_counts != -1)) {
|
||||||
|
+ if ((blocknr == first_transaction_blocknr) && dump_old && reverse_flag) {
|
||||||
|
fprintf(out_file, "Dump all %lld journal records.\n", cur_counts);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
From 29d83fef9e6eab139516afe433c03d975e85c25b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Srivathsa Dara <srivathsa.d.dara@oracle.com>
|
||||||
|
Date: Thu, 24 Aug 2023 06:56:34 +0000
|
||||||
|
Subject: [PATCH] debugfs: Use the hash_version from superblock if a file
|
||||||
|
system is opened
|
||||||
|
|
||||||
|
The debugfs program's dx_hash command computes the hash for the given
|
||||||
|
filename, taking the hash_seed and hash_version (i.e hash algorithm)
|
||||||
|
as arguments. So the user has to refer to the superblock to get these
|
||||||
|
values used by the filesystem. So if debugfs has an opened file
|
||||||
|
system, use those values from the current file system.
|
||||||
|
|
||||||
|
[ Fixed patch to avoid crashing when a file system is not opened. --TYT ]
|
||||||
|
|
||||||
|
Signed-off-by: Srivathsa Dara <srivathsa.d.dara@oracle.com>
|
||||||
|
Link: https://lore.kernel.org/r/20230824065634.2662858-1-srivathsa.d.dara@oracle.com
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
---
|
||||||
|
debugfs/htree.c | 11 +++++++++--
|
||||||
|
1 file changed, 9 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/debugfs/htree.c b/debugfs/htree.c
|
||||||
|
index a9f9211b..a3e95ddb 100644
|
||||||
|
--- a/debugfs/htree.c
|
||||||
|
+++ b/debugfs/htree.c
|
||||||
|
@@ -336,11 +336,18 @@ void do_dx_hash(int argc, char *argv[], int sci_idx EXT2FS_ATTR((unused)),
|
||||||
|
errcode_t err;
|
||||||
|
int c;
|
||||||
|
int hash_version = 0;
|
||||||
|
- __u32 hash_seed[4];
|
||||||
|
+ __u32 hash_seed[4] = { 0, };
|
||||||
|
int hash_flags = 0;
|
||||||
|
const struct ext2fs_nls_table *encoding = NULL;
|
||||||
|
|
||||||
|
- hash_seed[0] = hash_seed[1] = hash_seed[2] = hash_seed[3] = 0;
|
||||||
|
+ if (current_fs) {
|
||||||
|
+ hash_seed[0] = current_fs->super->s_hash_seed[0];
|
||||||
|
+ hash_seed[1] = current_fs->super->s_hash_seed[1];
|
||||||
|
+ hash_seed[2] = current_fs->super->s_hash_seed[2];
|
||||||
|
+ hash_seed[3] = current_fs->super->s_hash_seed[3];
|
||||||
|
+
|
||||||
|
+ hash_version = current_fs->super->s_def_hash_version;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
reset_getopt();
|
||||||
|
while ((c = getopt(argc, argv, "h:s:ce:")) != EOF) {
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
From d5296ff0c665c1f957252ee18f824ad666a34b78 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Baokun Li <libaokun1@huawei.com>
|
||||||
|
Date: Fri, 17 Feb 2023 18:09:22 +0800
|
||||||
|
Subject: [PATCH] tune2fs/fuse2fs/debugfs: save error information during
|
||||||
|
journal replay
|
||||||
|
|
||||||
|
Saving error information during journal replay, as in the kernel,
|
||||||
|
prevents information loss from making problems difficult to locate.
|
||||||
|
We save these error information until someone uses e2fsck to check
|
||||||
|
for and fix possible errors.
|
||||||
|
|
||||||
|
Signed-off-by: Baokun Li <libaokun1@huawei.com>
|
||||||
|
Reviewed-by: zhanchengbin <zhanchengbin1@huawei.com>
|
||||||
|
Reviewed-by: Jan Kara <jack@suse.cz>
|
||||||
|
Link: https://lore.kernel.org/r/20230217100922.588961-3-libaokun1@huawei.com
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
---
|
||||||
|
debugfs/journal.c | 17 ++++++++++++++++-
|
||||||
|
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/debugfs/journal.c b/debugfs/journal.c
|
||||||
|
index 5bac0d3b..79e3fff8 100644
|
||||||
|
--- a/debugfs/journal.c
|
||||||
|
+++ b/debugfs/journal.c
|
||||||
|
@@ -789,6 +789,8 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
|
||||||
|
char *fsname;
|
||||||
|
int fsflags;
|
||||||
|
int fsblocksize;
|
||||||
|
+ char *save;
|
||||||
|
+ __u16 s_error_state;
|
||||||
|
|
||||||
|
if (!(fs->flags & EXT2_FLAG_RW))
|
||||||
|
return EXT2_ET_FILE_RO;
|
||||||
|
@@ -808,6 +810,12 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
|
||||||
|
if (stats && stats->bytes_written)
|
||||||
|
kbytes_written = stats->bytes_written >> 10;
|
||||||
|
|
||||||
|
+ save = malloc(EXT4_S_ERR_LEN);
|
||||||
|
+ if (save)
|
||||||
|
+ memcpy(save, ((char *) fs->super) + EXT4_S_ERR_START,
|
||||||
|
+ EXT4_S_ERR_LEN);
|
||||||
|
+ s_error_state = fs->super->s_state & EXT2_ERROR_FS;
|
||||||
|
+
|
||||||
|
ext2fs_mmp_stop(fs);
|
||||||
|
fsname = fs->device_name;
|
||||||
|
fs->device_name = NULL;
|
||||||
|
@@ -818,11 +826,15 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
|
||||||
|
retval = ext2fs_open(fsname, fsflags, 0, fsblocksize, io_ptr, fsp);
|
||||||
|
ext2fs_free_mem(&fsname);
|
||||||
|
if (retval)
|
||||||
|
- return retval;
|
||||||
|
+ goto outfree;
|
||||||
|
|
||||||
|
fs = *fsp;
|
||||||
|
fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
|
||||||
|
fs->super->s_kbytes_written += kbytes_written;
|
||||||
|
+ fs->super->s_state |= s_error_state;
|
||||||
|
+ if (save)
|
||||||
|
+ memcpy(((char *) fs->super) + EXT4_S_ERR_START, save,
|
||||||
|
+ EXT4_S_ERR_LEN);
|
||||||
|
|
||||||
|
/* Set the superblock flags */
|
||||||
|
ext2fs_clear_recover(fs, recover_retval != 0);
|
||||||
|
@@ -832,6 +844,9 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fsp)
|
||||||
|
* the EXT2_ERROR_FS flag in the fs superblock if needed.
|
||||||
|
*/
|
||||||
|
retval = ext2fs_check_ext3_journal(fs);
|
||||||
|
+
|
||||||
|
+outfree:
|
||||||
|
+ free(save);
|
||||||
|
return retval ? retval : recover_retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
From 43a498e938887956f393b5e45ea6ac79cc5f4b84 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Date: Thu, 15 Jun 2023 00:17:01 -0400
|
||||||
|
Subject: [PATCH] resize2fs: use Direct I/O when reading the superblock for
|
||||||
|
online resizes
|
||||||
|
|
||||||
|
If the file system is mounted, the superblock can be changing while
|
||||||
|
resize2fs is trying to read the superblock, resulting in checksum
|
||||||
|
failures. One way of avoiding this problem is read the superblock
|
||||||
|
using Direct I/O, since the kernel makes sure that what gets written
|
||||||
|
to disk is self-consistent.
|
||||||
|
|
||||||
|
Suggested-by: Krister Johansen <kjlx@templeofstupid.com>
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
---
|
||||||
|
resize/main.c | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/resize/main.c b/resize/main.c
|
||||||
|
index 94f5ec6d..f914c050 100644
|
||||||
|
--- a/resize/main.c
|
||||||
|
+++ b/resize/main.c
|
||||||
|
@@ -403,6 +403,8 @@ int main (int argc, char ** argv)
|
||||||
|
|
||||||
|
if (!(mount_flags & EXT2_MF_MOUNTED))
|
||||||
|
io_flags = EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE;
|
||||||
|
+ if (mount_flags & EXT2_MF_MOUNTED)
|
||||||
|
+ io_flags |= EXT2_FLAG_DIRECT_IO;
|
||||||
|
|
||||||
|
io_flags |= EXT2_FLAG_64BITS | EXT2_FLAG_THREADS;
|
||||||
|
if (undo_file) {
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
From b31d5b582b4189a0ed27bced22276dd3f68c50a7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Eric Whitney <enwlinux@gmail.com>
|
||||||
|
Date: Fri, 21 Jul 2023 14:55:06 -0400
|
||||||
|
Subject: [PATCH] e2fsprogs: modify dumpe2fs to report free block ranges for
|
||||||
|
bigalloc
|
||||||
|
|
||||||
|
dumpe2fs has never been modified to correctly report block ranges
|
||||||
|
corresponding to free clusters in block allocation bitmaps from bigalloc
|
||||||
|
file systems. Rather than reporting block ranges covering all the
|
||||||
|
blocks in free clusters found in a block bitmap, it either reports just
|
||||||
|
the first block number in a cluster for a single free cluster, or a
|
||||||
|
range beginning with the first block number in the first cluster in a
|
||||||
|
series of free clusters, and ending with the first block number in the
|
||||||
|
last cluster in that series.
|
||||||
|
|
||||||
|
This behavior causes xfstest shared/298 to fail when run on a bigalloc
|
||||||
|
file system with a 1k block size. The test uses dumpe2fs to collect
|
||||||
|
a list of the blocks freed when files are deleted from a file system.
|
||||||
|
When the test deletes a file containing blocks located after the first
|
||||||
|
block in the last cluster in a series of clusters, dumpe2fs does not
|
||||||
|
report those blocks as free per the test's expectations.
|
||||||
|
|
||||||
|
Modify dumpe2fs to report full block ranges for free clusters. At the
|
||||||
|
same time, fix a small bug causing unnecessary !in_use() retests while
|
||||||
|
iterating over a block bitmap.
|
||||||
|
|
||||||
|
Signed-off-by: Eric Whitney <enwlinux@gmail.com>
|
||||||
|
Link: https://lore.kernel.org/r/20230721185506.1020225-1-enwlinux@gmail.com
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
---
|
||||||
|
misc/dumpe2fs.c | 12 ++++++------
|
||||||
|
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
|
||||||
|
index 7c080ed9f..d2d57fb0a 100644
|
||||||
|
--- a/misc/dumpe2fs.c
|
||||||
|
+++ b/misc/dumpe2fs.c
|
||||||
|
@@ -84,8 +84,7 @@ static void print_free(unsigned long group, char * bitmap,
|
||||||
|
unsigned long num, unsigned long offset, int ratio)
|
||||||
|
{
|
||||||
|
int p = 0;
|
||||||
|
- unsigned long i;
|
||||||
|
- unsigned long j;
|
||||||
|
+ unsigned long i, j;
|
||||||
|
|
||||||
|
offset /= ratio;
|
||||||
|
offset += group * num;
|
||||||
|
@@ -95,13 +94,14 @@ static void print_free(unsigned long group, char * bitmap,
|
||||||
|
if (p)
|
||||||
|
printf (", ");
|
||||||
|
print_number((i + offset) * ratio);
|
||||||
|
- for (j = i; j < num && !in_use (bitmap, j); j++)
|
||||||
|
+ for (j = i + 1; j < num && !in_use(bitmap, j); j++)
|
||||||
|
;
|
||||||
|
- if (--j != i) {
|
||||||
|
+ if (j != i + 1 || ratio > 1) {
|
||||||
|
fputc('-', stdout);
|
||||||
|
- print_number((j + offset) * ratio);
|
||||||
|
- i = j;
|
||||||
|
+ print_number(((j - 1 + offset) * ratio) +
|
||||||
|
+ ratio - 1);
|
||||||
|
}
|
||||||
|
+ i = j;
|
||||||
|
p = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
From 9058e09ee8d1543a185acdf0af4f72cb4d1b2aa7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ye Bin <yebin10@huawei.com>
|
||||||
|
Date: Sat, 20 Apr 2024 16:10:16 +0800
|
||||||
|
Subject: [PATCH] e2fsck: fix acl block leak when process orphan list
|
||||||
|
|
||||||
|
There's a issue:
|
||||||
|
[]$~/e2fsprogs/e2fsck/e2fsck -f scsi-disk2.img
|
||||||
|
e2fsck 1.47.0 (5-Feb-2023)
|
||||||
|
scsi-disk2.img: recovering journal
|
||||||
|
Clearing orphaned inode 12 (uid=0, gid=0, mode=0140777, size=0)
|
||||||
|
Pass 1: Checking inodes, blocks, and sizes
|
||||||
|
Extended attribute block 4247 has reference count 3, should be 2. Fix<y>? no
|
||||||
|
Pass 2: Checking directory structure
|
||||||
|
Pass 3: Checking directory connectivity
|
||||||
|
Pass 4: Checking reference counts
|
||||||
|
Pass 5: Checking group summary information
|
||||||
|
Free blocks count wrong (249189, counted=249188).
|
||||||
|
Fix<y>? no
|
||||||
|
Free inodes count wrong (65526, counted=65523).
|
||||||
|
Fix<y>? no
|
||||||
|
|
||||||
|
scsi-disk2.img: ***** FILE SYSTEM WAS MODIFIED *****
|
||||||
|
|
||||||
|
scsi-disk2.img: ********** WARNING: Filesystem still has errors **********
|
||||||
|
|
||||||
|
scsi-disk2.img: 10/65536 files (0.0% non-contiguous), 12955/262144 blocks
|
||||||
|
|
||||||
|
Above issue can reproduce as follows:
|
||||||
|
step1: socat UNIX-LISTEN:/home/test/mysocket.sock,mode=777,reuseaddr,fork EXEC:/home/test &
|
||||||
|
step2: setfacl some xattr for mysocket.sock
|
||||||
|
step3: cp -a /home/test/mysocket.sock /home/test/sock1
|
||||||
|
cp -a /home/test/mysocket.sock /home/test/sock2
|
||||||
|
step4: sync
|
||||||
|
step5: Power-off
|
||||||
|
step6: run e2fsck
|
||||||
|
|
||||||
|
As after commit 42475e281d22 add ext2fs_inode_has_valid_blocks() judgement in
|
||||||
|
release_inode_blocks() which means socket type file skip realse block include
|
||||||
|
ACL block. The kernel does not restrict the setting of extended attributes for
|
||||||
|
socket files. So this will lead to ACL block leak.
|
||||||
|
To solve above issue there's need to release ACL block for other kind of
|
||||||
|
special file.
|
||||||
|
|
||||||
|
Fixes: 42475e281d22 ("super.c (release_inode_blocks): Don't try to release the blocks if the orphaned inode is a device file, symlink, or some other kind of special file that doesn't have a block list.")
|
||||||
|
Signed-off-by: Ye Bin <yebin10@huawei.com>
|
||||||
|
---
|
||||||
|
e2fsck/super.c | 3 ++-
|
||||||
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/e2fsck/super.c b/e2fsck/super.c
|
||||||
|
index ec28426..79460d9 100644
|
||||||
|
--- a/e2fsck/super.c
|
||||||
|
+++ b/e2fsck/super.c
|
||||||
|
@@ -196,7 +196,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
|
__u32 count;
|
||||||
|
|
||||||
|
if (!ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(inode)))
|
||||||
|
- return 0;
|
||||||
|
+ goto release_acl;
|
||||||
|
|
||||||
|
pb.buf = block_buf + 3 * ctx->fs->blocksize;
|
||||||
|
pb.ctx = ctx;
|
||||||
|
@@ -240,6 +240,7 @@ static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
|
||||||
|
if (inode->i_links_count)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
+release_acl:
|
||||||
|
blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode));
|
||||||
|
if (blk) {
|
||||||
|
retval = ext2fs_adjust_ea_refcount3(fs, blk, block_buf, -1,
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
From 1bd16e790308f92e89a5dfbd40ab9e164fe88aa9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Date: Thu, 11 Aug 2022 22:16:41 -0400
|
||||||
|
Subject: [PATCH] e2fsck: when mutating file name make sure its length never
|
||||||
|
exceeds 255
|
||||||
|
|
||||||
|
E2fsck will attempt to mutate filenames to ensure uniqueness if
|
||||||
|
necessary. If there are two unique filenames that are 254 or 255
|
||||||
|
characters in length and do not contain the '~' character, the
|
||||||
|
mutate_name() function would create a filename which is 256 bytes
|
||||||
|
long, which is not a legal filename in Linux. Adjust the mutate_name
|
||||||
|
function to avoid this possibility.
|
||||||
|
|
||||||
|
Addresses-Coverity-Bug: 1500768
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
---
|
||||||
|
e2fsck/rehash.c | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
|
||||||
|
index 8cc36f24..210cfdf2 100644
|
||||||
|
--- a/e2fsck/rehash.c
|
||||||
|
+++ b/e2fsck/rehash.c
|
||||||
|
@@ -414,6 +414,8 @@ static void mutate_name(char *str, unsigned int *len)
|
||||||
|
l += 2;
|
||||||
|
else
|
||||||
|
l = (l+3) & ~3;
|
||||||
|
+ if (l > 255)
|
||||||
|
+ l = 255;
|
||||||
|
str[l-2] = '~';
|
||||||
|
str[l-1] = '0';
|
||||||
|
*len = l;
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
126
0048-reisze2fs-sanity-check-free-block-group-counts-when-.patch
Normal file
126
0048-reisze2fs-sanity-check-free-block-group-counts-when-.patch
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
From 265f88904e8d47658852e8d41447e727d799cea8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Date: Tue, 28 Dec 2021 12:33:15 -0500
|
||||||
|
Subject: [PATCH] reisze2fs: sanity check free block group counts when
|
||||||
|
calculating minimum size
|
||||||
|
|
||||||
|
If one or more block group descriptor's free blocks count is insane,
|
||||||
|
it's possible this can lead to a infinite loop in the function
|
||||||
|
calculate_minimum_resize_size(), which is called by resize2fs -P or
|
||||||
|
resize2fs -M.
|
||||||
|
|
||||||
|
Add some sanity checks to avoid this. In the case where the file
|
||||||
|
system is corrupt, this will result in resize2fs -P reporting an
|
||||||
|
incorrect value, but that's OK, since when we try to do an actual
|
||||||
|
resize operation, resize2fs requires that the file system be freshly
|
||||||
|
checked using e2fsck.
|
||||||
|
|
||||||
|
https://github.com/tytso/e2fsprogs/issues/94
|
||||||
|
|
||||||
|
Fixes: ac94445fc01f ("resize2fs: make minimum size estimates more reliable for mounted fs")
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
---
|
||||||
|
resize/resize2fs.c | 13 +++++++++--
|
||||||
|
tests/r_corrupt_fs/expect | 4 ++++
|
||||||
|
tests/r_corrupt_fs/name | 1 +
|
||||||
|
tests/r_corrupt_fs/script | 45 +++++++++++++++++++++++++++++++++++++++
|
||||||
|
4 files changed, 61 insertions(+), 2 deletions(-)
|
||||||
|
create mode 100644 tests/r_corrupt_fs/expect
|
||||||
|
create mode 100644 tests/r_corrupt_fs/name
|
||||||
|
create mode 100644 tests/r_corrupt_fs/script
|
||||||
|
|
||||||
|
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
|
||||||
|
index 73174be0..b9783e8c 100644
|
||||||
|
--- a/resize/resize2fs.c
|
||||||
|
+++ b/resize/resize2fs.c
|
||||||
|
@@ -3002,8 +3002,17 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
|
||||||
|
/* calculate how many blocks are needed for data */
|
||||||
|
data_needed = ext2fs_blocks_count(fs->super);
|
||||||
|
for (grp = 0; grp < fs->group_desc_count; grp++) {
|
||||||
|
- data_needed -= calc_group_overhead(fs, grp, old_desc_blocks);
|
||||||
|
- data_needed -= ext2fs_bg_free_blocks_count(fs, grp);
|
||||||
|
+ __u32 n = ext2fs_bg_free_blocks_count(fs, grp);
|
||||||
|
+
|
||||||
|
+ if (n > EXT2_BLOCKS_PER_GROUP(fs->super))
|
||||||
|
+ n = EXT2_BLOCKS_PER_GROUP(fs->super);
|
||||||
|
+ n += calc_group_overhead(fs, grp, old_desc_blocks);
|
||||||
|
+ if (data_needed < n) {
|
||||||
|
+ if (flags & RESIZE_DEBUG_MIN_CALC)
|
||||||
|
+ printf("file system appears inconsistent?!?\n");
|
||||||
|
+ return ext2fs_blocks_count(fs->super);
|
||||||
|
+ }
|
||||||
|
+ data_needed -= n;
|
||||||
|
}
|
||||||
|
#ifdef RESIZE2FS_DEBUG
|
||||||
|
if (flags & RESIZE_DEBUG_MIN_CALC)
|
||||||
|
diff --git a/tests/r_corrupt_fs/expect b/tests/r_corrupt_fs/expect
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..fe0f2bc4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/r_corrupt_fs/expect
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+mke2fs -q -F -t ext4 -o Linux -b 1024 test.img 32M
|
||||||
|
+debugfs -w -R "set_bg 1 free_blocks_count 65536" /tmp/foo.img
|
||||||
|
+resize2fs -P /tmp/foo.img
|
||||||
|
+Estimated minimum size of the filesystem: 6604
|
||||||
|
diff --git a/tests/r_corrupt_fs/name b/tests/r_corrupt_fs/name
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..ed627419
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/r_corrupt_fs/name
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+resize2fs -P of a corrupted file system
|
||||||
|
diff --git a/tests/r_corrupt_fs/script b/tests/r_corrupt_fs/script
|
||||||
|
new file mode 100644
|
||||||
|
index 00000000..08af91ed
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/tests/r_corrupt_fs/script
|
||||||
|
@@ -0,0 +1,45 @@
|
||||||
|
+if ! test -x $RESIZE2FS_EXE -o ! -x $DEBUGFS_EXE; then
|
||||||
|
+ echo "$test_name: $test_description: skipped (no debugfs/resize2fs)"
|
||||||
|
+ return 0
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
+OUT=$test_name.log
|
||||||
|
+if [ -f $test_dir/expect.gz ]; then
|
||||||
|
+ EXP=$test_name.tmp
|
||||||
|
+ gunzip < $test_dir/expect.gz > $EXP1
|
||||||
|
+else
|
||||||
|
+ EXP=$test_dir/expect
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
+echo mke2fs -q -F -t ext4 -o Linux -b 1024 test.img 32M > $OUT.new
|
||||||
|
+$MKE2FS -q -F -t ext4 -o Linux -b 1024 $TMPFILE 32M >> $OUT.new 2>&1
|
||||||
|
+
|
||||||
|
+echo debugfs -w -R \"set_bg 1 free_blocks_count 65536\" /tmp/foo.img >> $OUT.new
|
||||||
|
+$DEBUGFS -w -R "set_bg 1 free_blocks_count 65536" $TMPFILE > /dev/null 2>&1
|
||||||
|
+
|
||||||
|
+if type timeout > /dev/null 2>&1 ; then
|
||||||
|
+ TIMEOUT="timeout -v 30s"
|
||||||
|
+else
|
||||||
|
+ TIMEOUT=
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
+echo resize2fs -P /tmp/foo.img >> $OUT.new
|
||||||
|
+$TIMEOUT $RESIZE2FS -P $TMPFILE >> $OUT.new 2>&1
|
||||||
|
+
|
||||||
|
+sed -f $cmd_dir/filter.sed < $OUT.new > $OUT
|
||||||
|
+
|
||||||
|
+rm -f $TMPFILE $OUT.new
|
||||||
|
+
|
||||||
|
+cmp -s $OUT $EXP
|
||||||
|
+status=$?
|
||||||
|
+
|
||||||
|
+if [ "$status" = 0 ] ; then
|
||||||
|
+ echo "$test_name: $test_description: ok"
|
||||||
|
+ touch $test_name.ok
|
||||||
|
+else
|
||||||
|
+ echo "$test_name: $test_description: failed"
|
||||||
|
+ diff $DIFF_OPTS $EXP $OUT > $test_name.failed
|
||||||
|
+ rm -f $test_name.tmp
|
||||||
|
+fi
|
||||||
|
+
|
||||||
|
+unset IMAGE OUT EXP TIMEOUT
|
||||||
|
--
|
||||||
|
2.33.0
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
Name: e2fsprogs
|
Name: e2fsprogs
|
||||||
Version: 1.46.4
|
Version: 1.46.4
|
||||||
Release: 22
|
Release: 27
|
||||||
Summary: Second extended file system management tools
|
Summary: Second extended file system management tools
|
||||||
License: GPLv2+ and LGPLv2 and MIT
|
License: GPLv2+ and LGPLv2 and MIT
|
||||||
URL: http://e2fsprogs.sourceforge.net/
|
URL: http://e2fsprogs.sourceforge.net/
|
||||||
@ -47,19 +47,26 @@ Patch37: 0037-libext2fs-fix-ext2fs_compare_generic_bmap-logic.patch
|
|||||||
Patch38: 0038-Quiet-unused-variable-warnings.patch
|
Patch38: 0038-Quiet-unused-variable-warnings.patch
|
||||||
Patch39: 0039-ext2fs-Use-64bit-lseek-when-_FILE_OFFSET_BITS-is-64.patch
|
Patch39: 0039-ext2fs-Use-64bit-lseek-when-_FILE_OFFSET_BITS-is-64.patch
|
||||||
Patch40: 0040-e2fsck-fix-bad-htree-checksums-in-preen-mode.patch
|
Patch40: 0040-e2fsck-fix-bad-htree-checksums-in-preen-mode.patch
|
||||||
|
Patch41: 0041-debugfs-Fix-infinite-loop-when-dump-log.patch
|
||||||
|
Patch42: 0042-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch
|
||||||
|
Patch43: 0043-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch
|
||||||
|
Patch44: 0044-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch
|
||||||
|
Patch45: 0045-modify-dumpe2fs-to-report-free-block-ranges-for-bigalloc.patch
|
||||||
|
Patch46: 0046-e2fsck-fix-acl-block-leak-when-process-orphan-list.patch
|
||||||
|
Patch47: 0047-e2fsck-when-mutating-file-name-make-sure-its-length-.patch
|
||||||
|
Patch48: 0048-reisze2fs-sanity-check-free-block-group-counts-when-.patch
|
||||||
|
|
||||||
BuildRequires: gcc pkgconfig texinfo
|
BuildRequires: gcc pkgconfig texinfo
|
||||||
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
||||||
BuildRequires: audit
|
BuildRequires: audit
|
||||||
Recommends: %{name}-help = %{version}-%{release}
|
Recommends: %{name}-help = %{version}-%{release}
|
||||||
|
|
||||||
Provides: e2fsprogs-libs%{?_isa} e2fsprogs-libs
|
Provides: e2fsprogs-libs%{?_isa} = %{version}-%{release} e2fsprogs-libs = %{version}-%{release}
|
||||||
Obsoletes: e2fsprogs-libs
|
Obsoletes: e2fsprogs-libs < %{version}
|
||||||
Provides: libcom_err%{?_isa} libcom_err
|
Provides: libcom_err%{?_isa} = %{version}-%{release} libcom_err = %{version}-%{release}
|
||||||
Obsoletes: libcom_err
|
Obsoletes: libcom_err < %{version}
|
||||||
Provides: libss%{?_isa} libss
|
Provides: libss%{?_isa} = %{version}-%{release} libss = %{version}-%{release}
|
||||||
Obsoletes: libss
|
Obsoletes: libss < %{version}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
The e2fsprogs package consists of a lot of tools for users to create,
|
The e2fsprogs package consists of a lot of tools for users to create,
|
||||||
@ -74,12 +81,12 @@ Requires: gawk
|
|||||||
Requires: pkgconfig
|
Requires: pkgconfig
|
||||||
Requires(post): info
|
Requires(post): info
|
||||||
Requires(preun): info
|
Requires(preun): info
|
||||||
Provides: libcom_err-devel%{?_isa} libcom_err-devel
|
Provides: libcom_err-devel%{?_isa} = %{version}-%{release} libcom_err-devel = %{version}-%{release}
|
||||||
Obsoletes: libcom_err-devel
|
Obsoletes: libcom_err-devel < %{version}
|
||||||
Provides: libss-devel%{?_isa} libss-devel
|
Provides: libss-devel%{?_isa} = %{version}-%{release} libss-devel = %{version}-%{release}
|
||||||
Obsoletes: libss-devel
|
Obsoletes: libss-devel < %{version}
|
||||||
Provides: e2fsprogs-static{?_isa} e2fsprogs-static
|
Provides: e2fsprogs-static{?_isa} = %{version}-%{release} e2fsprogs-static = %{version}-%{release}
|
||||||
Obsoletes: e2fsprogs-static
|
Obsoletes: e2fsprogs-static < %{version}
|
||||||
|
|
||||||
%description devel
|
%description devel
|
||||||
This package provides libraries and header files to develop
|
This package provides libraries and header files to develop
|
||||||
@ -188,6 +195,21 @@ exit 0
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu May 30 2024 zhangjian <zhangjian496@huawei.com> - 1.46.4-27
|
||||||
|
- backport upstream patch
|
||||||
|
|
||||||
|
* Tue May 07 2024 zhangxingrong <zhangxingrong@uniontech.com> - 1.46.4-26
|
||||||
|
- backport upstream patch
|
||||||
|
|
||||||
|
* Sun Apr 7 2024 haowenchao <haowenchao2@huawei.com> - 1.46.4-25
|
||||||
|
- Backports from mainline
|
||||||
|
|
||||||
|
* Tue Dec 19 2023 haowenchao <haowenchao2@huawei.com> - 1.46.4-24
|
||||||
|
- debugfs: Fix infinite loop when dump log
|
||||||
|
|
||||||
|
* Thu Nov 09 2023 Xinliang Liu <xinliang.liu@linaro.org> - 1.46.4-23
|
||||||
|
- Fix rpmlint Provides/Obsoletes unversioned warnings to fix dnf update
|
||||||
|
|
||||||
* Mon Oct 30 2023 volcanodragon <linfeilong@huawei.com> - 1.46.4-22
|
* Mon Oct 30 2023 volcanodragon <linfeilong@huawei.com> - 1.46.4-22
|
||||||
- e2fsck fix bad htree checksum in preen mode
|
- e2fsck fix bad htree checksum in preen mode
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user