configure: Use FORTIFY_SOURCE=3 when hardening is enabled
FORTIFY_SOURCE=3 provides much more robust checks for buffer overruns
and other memory bugs[1]. It requires gcc 12 and glibc 2.34 which
should be available on most modern distributions (which are the ones
that use --enable-hardening).
mke2fs: implement timestamp clamping if SOURCE_DATE_EPOCH is set
When copying files to the newly created file system using "mke2fs -d",
and there are timestamps greater than what is specified by
SOURCE_DATE_EPOCH, clamp the timestamp to the SOURCE_DATE_EPOCH
timestamp.
libext2fs: use a safe_getenv() function everywhere
Hoist safe_getenv() from test_io.c and unix_io.c to a globally
exported ext2fs_safe_getenv() and use it instead of getenv() in
libext2fs. This provides a bit more safety if e2fsprogs programs are
used in setuid contexts.
Fix coverity false positives introduced by the post-2038 changes
Commit ca8bc9240a00 ("Add post-2038 timestamp support...") did things
like casting a 64-bit unsigned integer into a signed 32-bit integer
deliberately; but Coverity thinks this is a bug. So mask off the bits
to make it clear this was deliberate.
e2fsck: make sure get_backup_sb() works when ctx is NULL
The print_e2fsck_message() function can call get_backup_sb() with the
ctx variable set to NULL. In that case, we can't dereference
ctx->filesystem_name; instead, we can get the size of the file system
from the ext2fs_block_count(fs->super).
Align function prototypes for libss's request handler function
Clang 17's Undefined Behaviour Sanitizer will throw run-time warnings
if a function pointer is dereferenced with a different function
signature than one in the pointer --- even if the difference is a
missing const qualifier. To fix regression test failures, change
declarations of argv to use ss_argv_t instead of an inconsistently
open-coded type.
The mkgnutar.pl file only works if the developer had a specific
username and uid. In addition, if it is used, the round-trip from tar
to an ext4 file system and back to tar isn't properly tested. So only
use mkgnutar.pl if the system doesn't have GNU TAR.
In addition, make sure all of the temp files created by the test are
deleted when the test is completed.
FreeBSD 14 has changed the definition of qsort_r to align it with the
POSIX, but it did this with a #define. So when sort_r.h tries to
provide a function prototype, surround the function name with
parenthesis so it doesn't get expanded by FreeBSD's #define.
Debugfs's stat command called ext2fs_inode_xtime_get() with a struct
inode * instead of a struct large_inode *. As a result, printing
inode timestamps will be incorrect if the time value is larger than
2**32.
Fixes: ca8bc9240a00 ("Add post-2038 timestamp support to e2fsprogs") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc: update mke2fs's man page regarding the default inode size
Since a23b50cd ("mke2fs: warn about missing y2038 support when
formatting fresh ext4 fs"), the default inode size is 256 bytes
for all filesystems, including small and floppy, except for the
Hurd since it currently only supports 128-byte inodes.
How timestamps are encoded in inodes and superblocks are different.
Unfortunately, commit ca8bc9240a00 which added post-2038 timestamps
was (a) overwriting adjacent superblock fields and/or attempting
unaligned writes to a 8-bit field from a 32-bit pointer, and (b) using
the incorrect encoding for timestamps stored in inodes. Fix both of
these issues, which were found thanks to UBSAN.
Fixes: ca8bc9240a00 ("Add post-2038 timestamp support to e2fsprogs") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
mke2fs: the -d option can now handle tarball input
If archive.h is available during compilation, enable mke2fs to read a
tarball as input. Since libarchive.so.13 is opened with dlopen,
libarchive is not a hard library dependency of the resulting binary.
In comparison with feeding a directory tree to mke2fs via -d this has
the following advantages:
- no superuser privileges, nor fakeroot, nor unshared user namespaces
are needed to create filesystems with arbitrary ownership information
and special files like device nodes which otherwise require being root
- by reading a tarball from standard input, no temporary files need to
be written out first as mke2fs can be used as part of a shell pipeline
which reduces disk usage and makes the conversion independent of the
underlying file system
A round-trip from tarball to ext4 to tarball yields bit-by-bit identical
results
Signed-off-by: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Commit ca8bc9240a00 ("Add post-2038 timestamp support to e2fsprogs")
was never built or tested on a 32-bit. It introduced some build
problems when time_t is a 32-bit integer, and it exposed some test
bugs. Fix them.
Fixes: ca8bc9240a00 ("Add post-2038 timestamp support to e2fsprogs") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck: don't try backup superblocks beyond the size of the device
Commit f7ef5f3e356d ("e2fsck: check all sparse_super backups") tries
to limit the number of block groups to search for backup superblocks
based on ctx->num_blocks. Unfortunately, get_backup_sb() gets called
before ctx->num_blocks is set, so we try all block groups up to 2**32
- 1. Not only does this waste time trying to read from blocks that
don't exist, it triggers the UBSAN checker when multiplying a very
large number by the block size.
Fix this by using ext2fs_get_Device_size(), and if that isn't
available, arbitrarily cap things so that we search block groups up to
128.
Sam James [Tue, 7 Nov 2023 23:31:20 +0000 (23:31 +0000)]
ext2fs: fix -Walloc-size
GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
lib/ext2fs/hashmap.c:37:36: warning: allocation of insufficient size ‘1’ for type ‘struct ext2fs_hashmap’ with size ‘20’ [-Walloc-size]
```
The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```
So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(...)`. GCC then sees we're not
doing anything wrong.
Wenchao Hao [Fri, 17 Nov 2023 10:23:15 +0000 (18:23 +0800)]
debugfs: fix infinite loop while dumping the journal
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 "wrapped_flag" to mark if logdump has
reached to tail of logarea set in macro WRAP().
If wrapped_flag is true, and we comes to first_transaction_blocknr
again, just break the logdump loop.
[ Renamed reverse_flag to wrapped_flag to make it clearer what it is. -- TYT ]
Anssi Hannula [Tue, 7 Nov 2023 09:46:53 +0000 (11:46 +0200)]
resize2fs: avoid constantly flushing while moving blocks
resize2fs block_mover() flushes data after each extent and, curiously,
only if progress indicator is enabled, every inode_blocks_per_group
blocks.
This significantly affects performance, e.g. on a tested large
filesystem on top of MD-RAID6+LVM+dm-crypt these flush calls reduce the
operation rate from approx. 500MB/s to 5MB/s, causing extremely long
shrinking times for large size deltas (70TB in my case).
Since this step performs just plain data copying and does not e.g. save
any progress/checkpoint information or similar metadata, it seems like
this flushing is of very limited usefulness, especially when considering
the (in some cases) 100x performance impact.
Remove the mid-operation flushes and only flush after all blocks have
been moved.
tests: new test to check quota after a bad inode deallocation
This new test validates e2fsck by verifying that quota is updated after a bad
inode is deallocated. It mimics fstest ext4/019 by including a filesystem image
where a symbolic link was created to an existing file, using a long symlink
name. This symbolic link was then wiped with:
tests: new test to check quota after directory optimization
This new test validates e2fsck by verifying that quota data is updated after a
directory optimization is performed. This issue was initially found by fstest
ext4/014, and this test was based on it. It includes a filesystem image where
the lost+found directory is unlinked after a new link to it is created:
e2fsck: update quota when deallocating a bad inode
If a bad inode is found it will be deallocated. However, if the filesystem has
quota enabled, the quota information isn't being updated accordingly. This
issue was detected by running fstest ext4/019.
This patch fixes the issue by decreasing the inode count from the
quota and, if blocks are also being released, also subtract them as well.
While there, and as suggested by Andreas Dilger, the deallocate_inode()
function documentation is also updated by this patch to make it clear what
that function really does.
e2fsck: update quota accounting after directory optimization
In "Pass 3A: Optimizing directories", a directory may have it's size reduced.
If that happens and quota is enabled in the filesystem, the quota information
will be incorrect because it doesn't take the rehash into account. This issue
was detected by running fstest ext4/014.
This patch simply updates the quota data accordingly, after the directory is
written and it's size has been updated.
According to the mke2fs man page, the supported cluster-size values
for an ext4 filesystem are 2048 to 256M bytes. However, this is not
the case.
When mkfs is run to create a filesystem with following specifications:
* 1k blocksize and cluster-size greater than 32M
* 2k blocksize and cluster-size greater than 64M
* 4k blocksize and cluster-size greater than 128M
mkfs fails with "Invalid argument passed to ext2 library while trying
to create journal" error. In general, when the cluster-size to blocksize
ratio is greater than 32k, mkfs fails with this error.
Went through the code and found out that the function
`ext2fs_new_range()` is the source of this error. This is because when
the cluster-size to blocksize ratio exceeds 32k, the length argument
to the function `ext2fs_new_range()` results in 0. Hence, the error.
This patch corrects the valid cluster-size values.
Li Dongyang [Mon, 25 Sep 2023 06:08:01 +0000 (16:08 +1000)]
mke2fs: do not set the BLOCK_UNINIT on groups has GDT
This patch prepares the expansion of GDT blocks beyond a
single group, by make mke2fs to not set BLOCK_UNINIT on
groups with GDT blocks, block/inode bitmaps, or inode table
blocks allocated.
Otherwise, we still rely on kernel side to initialize the
block bitmap if the groups has BLOCK_UNINIT set, and the
kernel doesn't know a group could have GDT blocks allocated,
so it would make an bad block bitmap.
As a result, expect output of several tests needs to be changed,
especially if the test uses dumpe2fs to print the group summary.
Li Dongyang [Mon, 25 Sep 2023 06:08:00 +0000 (16:08 +1000)]
mke2fs: set free blocks accurately for groups has GDT
This patch is part of the preparation required to allow
GDT blocks expand beyond a single group,
it introduces 2 new interfaces:
- ext2fs_count_used_blocks(), to return the blocks used
in the bitmap range.
- ext2fs_reserve_super_and_bgd2() to return blocks used by
superblock/GDT blocks for every group, by looking up blocks used.
Andreas Dilger [Mon, 4 Sep 2023 04:57:42 +0000 (14:57 +1000)]
e2fsck: check all sparse_super backups
Teach e2fsck to look for backup super blocks in the "sparse_super"
groups, by checking group #1 first and then powers of 3^n, 5^n,
and 7^n, up to the limit of available block groups.
Export ext2fs_list_backups() function to efficiently iterate groups
for backup sb/GDT instead of checking every group. Ensure that the
group counters do not try to overflow the 2^32-1 group limit, and
try to limit scanning to the size of the block device (if available).
Li Dongyang [Mon, 4 Sep 2023 04:58:06 +0000 (14:58 +1000)]
mke2fs: batch zeroing inode table
For flex_bg enabled fs, we could merge the
inode table blocks into a contiguous range,
this improves mke2fs time on large devices
when lazy_itable_init is disabled.
On a 977TB device, unpatched mke2fs was running
for 449m10s before getting terminated manually.
strace shows huge number of fallocate, given the
offset from fallocate it has done 41% of the inode
tables, the estimated time needed would be 1082m.
unpatched patched
real 449m10.954s 4m20.531s
user 0m18.217s 0m16.147s
sys 0m20.311s 0m8.944s
libext2fs: always refuse to open a file system with a zero s_desc_size
Commit 42c11edd0863 ("ext2fs_open[2](), return an error if s_desc_size
is too large") added a check for an insanely large s_desc_size to
prevent some failures triggered by fuzz testing. However, it would
allow e2fsck to fall back to recover the file system by using the
backup superblocks by having e2fsck pass the flag
EXT2_FLAG_IGNORE_SB_ERRORS. But by allowing an s_desc_Size of zero,
it's possible that e2fsck will die with a division of zero error.
With this fix, e2fsck will now print an error message and exit
instead.
https://github.com/tytso/e2fsprogs/issues/183
Fixes: 42c11edd0863 ("ext2fs_open[2](), return an error if s_desc_size is too large") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Andreas Dilger [Wed, 27 Sep 2023 05:40:16 +0000 (23:40 -0600)]
Add post-2038 timestamp support to e2fsprogs
The ext4 kernel code implemented support for s_mtime_hi,
s_wtime_hi, and related timestamp fields to avoid timestamp
overflow in 2038, but similar handling is not in e2fsprogs.
Add helper macros for the superblock _hi timestamp fields
ext2fs_super_tstamp_get() and ext2fs_super_tstamp_set().
Add helper macro for inode _extra timestamp fields
ext2fs_inode_xtime_get() and ext2fs_inode_xtime_set().
Add helper macro ext2fs_actual_inode_size() to avoid open
coding the i_extra_isize check in multiple places.
Remove inode_time_to_string() since this is unused once callers
change to time_to_string(ext2fs_inode_xtime_get()) directly.
Fix inode_includes() macro to properly wrap "inode" parameter,
and rename to ext2fs_inode_includes() to avoid potential name
clashes. Use this to check inode field inclusion in debugfs
instead of bare constants for inode field offsets.
Use these interfaces to access timestamps in debugfs, e2fsck,
libext2fs, fuse2fs, tune2fs, and e2undo.
Eric Biggers [Wed, 1 Mar 2023 03:45:18 +0000 (19:45 -0800)]
libext2fs: fix ext2fs_get_device_size2() return value on Windows
Creating a file system on Windows without a pre-existing file stopped
working because the Windows version of ext2fs_get_device_size2() doesn't
return ENOENT if the file doesn't exist. Fix this.
(Note: Filesystem state == "clean" means that EXT2_VALID_FS is set in
the superblock s_state field; "not clean with errors" means that the
flag is not set.)
I bet the "journal only" preen doesn't actually reset the filesystem
state either:
# e2fsck -E journal_only -p /dev/sda
# dumpe2fs /dev/sda -h | grep state
dumpe2fs 1.47.1~WIP-2023-12-27 (27-Dec-2023)
Filesystem state: not clean with errors
Nope.
So now I know what happened -- when mounting an ext* filesystem that
doesn't have a journal, the driver clears EXT2_VALID_FS from the primary
superblock. This forces the system to run e2fsck after a crash, because
that's what you have to do for unjournalled filesystems.
The "e2fsck -E journal_only -p" call in e2scrub only replays the
journal. Since there is no journal, it exits almost immediately.
That's the intended behavior, but then it means that the "e2fsck -fy"
call immediately after sees that the superblock doesn't have
EXT2_VALID_FS set, sets it, and makes e2fsck return 1.
So that's why you're getting the e2scrub failures.
Contrast this to what you get when the filesystem has a journal:
Filesystems with journals retain their EXT4_VALID_FS state when they're
mounted.
Hmm. What e2scrub should do about unjournalled filesystems is a thorny
question. My initial thought is that it should skip them, because a
mounted unjournalled filesystem cannot by definition be kept consistent.
Therefore, teach e2scrub_all to avoid them and e2scrub to fail them at
the onset.
Restricting the scope of e2scrub sucks, but in the meantime at least it
means that your filesystem isn't massively corrupt. Thanks for the
metadump, it was very useful for root cause analysis.
Darrick J. Wong [Wed, 10 Jan 2024 05:57:24 +0000 (21:57 -0800)]
debian: don't restart e2scrub_all when upgrading package
When installing or upgrading the e2fsprogs package, only start the
e2scrub_all timer and the reaping service. Don't restart e2scrub_all
itself, because that will kill any scrubs in progress, which will
trigger the failure reporting.
Darrick J. Wong [Sun, 31 Dec 2023 20:39:03 +0000 (12:39 -0800)]
e2scrub_fail: move executable script to /usr/libexec
Per FHS 3.0, non-PATH executable binaries are supposed to live under
/usr/libexec, not /usr/lib. e2scrub_fail is an executable script, so
move it to libexec in case some distro some day tries to mount /usr/lib
as noexec or something. Also, there's no reason why these scripts need
to be put under an arch-dependent path.
Zhiqiang Liu [Mon, 20 Mar 2023 05:04:34 +0000 (13:04 +0800)]
tune2fs: check whether filesystem is in use for I_flag and Q_flag test
For changing inode size (-I) and setting quota fearture (-Q), tune2fs
only check whether the filesystem is umounted. Considering mount
namepspaces, the filesystem is umounted, however it already be left
in other mount namespace.
So we add one check whether the filesystem is not in use with using
EXT2_MF_BUSY flag, which can indicate the device is already opened
with O_EXCL, as suggested by Ted.
Emoly Liu [Fri, 14 Jul 2023 00:59:58 +0000 (10:59 +1000)]
e2image: correct group descriptors size in ext2fs_image_super_read()
In function ext2fs_image_super_read(), the size of block group
descriptors should be (fs->blocksize * fs->desc_blocks), but not
(fs->blocksize * fs->group_desc_count).
Theodore Ts'o [Tue, 16 Jan 2024 02:59:49 +0000 (21:59 -0500)]
debugfs: dx_hash: honor the unsigned hash flag if a file system is opened
If we are using the hash seed and hash version from an open file
systenm, then we should also use the unsigned version of the hash
algorithm if the superblock as the unsigned hash flag set.
Darrick J. Wong [Thu, 24 Aug 2023 22:26:31 +0000 (15:26 -0700)]
e2fsprogs: don't allow udisks to automount ext4 filesystems with no prompt
The unending stream of syzbot bug reports and overwrought filing of CVEs
for corner case handling (i.e. things that distract from actual user
complaints) in ext4 has generated all sorts of of overheated rhetoric
about how every bug is a Serious Security Issue(tm) because anyone can
craft a malicious filesystem on a USB stick, insert the stick into a
victim machine, and mount will trigger a bug in the kernel driver that
leads to some compromise or DoS or something.
I thought that nobody would be foolish enough to automount an ext4
filesystem. What a fool I was! It turns out that udisks can be told
that it's okay to automount things, and then GNOME will do exactly that.
Including mounting mangled ext4 filesystems!
<delete angry rant about poor decisionmaking and armchair fs developers
blasting us on X while not actually doing any of the work>
Turn off /this/ idiocy by adding a udev rule to tell udisks not to
automount ext4 filesystems.
This will not stop a logged in user from unwittingly inserting a
malicious storage device and pressing [mount] and getting breached.
This is not a substitute for a thorough audit of all codebases. This is
not a substitute for lklfuse. This does not solve the general problem
of in-kernel fs drivers being a huge attack surface. I just want a
vacation from the sh*tstorm of bad ideas and threat models that I never
agreed to support.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Darrick J. Wong [Fri, 17 Mar 2023 18:19:11 +0000 (11:19 -0700)]
e2scrub: fix pathname escaping across all service definitions
systemd services provide an "instance name" that can be associated with
a particular invocation of a service. This allows service users to
invoke multiple copies of a service, each with a unique string. For
e2scrub, we pass the mountpoint of the filesystem as the instance name.
However, systemd services aren't supposed to have slashes in them, so
we're supposed to escape them.
The canonical escaping scheme for pathnames is defined by the
systemd-escape --path command. Unfortunately, we've been adding our own
opinionated sauce for years, to work around the fact that --path didn't
quite work right in systemd before January 2017. The special sauce is
incorrect, and we no longer care about systemd of 7 years past.
Clean up this mess by following the systemd escaping scheme throughout
the service units. Now we can use the '%f' specifier in them, which
makes things a lot less complicated.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Srivathsa Dara [Thu, 24 Aug 2023 06:56:34 +0000 (06:56 +0000)]
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 ]
Andreas Dilger [Wed, 10 May 2023 05:18:49 +0000 (23:18 -0600)]
ext2fs: don't retry discard/zeroout repeatedly
Call safe_getenv(UNIX_IO_NOZEROOUT) once when the device is
opened and set CHANNEL_FLAG_NOZEROOUT if present instead of
getting uid/euid/getenv every time unix_zeroout() is called.
For unix_discard() and unix_zeroout() don't continue to call
them if the block device doesn't support these operations.
Baokun Li [Fri, 17 Feb 2023 10:09:22 +0000 (18:09 +0800)]
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.
Baokun Li [Fri, 17 Feb 2023 10:09:21 +0000 (18:09 +0800)]
e2fsck: save EXT2_ERROR_FS flag during journal replay
When repairing a file system with s_errno missing from the journal
superblock but the file system superblock contains the ERROR_FS flag,
the ERROR_FS flag on the file system image is overwritten after the
journal replay, followed by a reload of the file system data from disk
and the ERROR_FS flag in memory is overwritten. Also s_errno is not set
and the ERROR_FS flag is not reset. Therefore, when checked later, no
forced check is performed, which makes it possible to have some errors
hidden in the disk image, which may make it read-only when using the
file system. So we save the ERROR_FS flag to the superblock after the
journal replay, instead of just relying on the jsb->s_errno to do this.
Andreas Dilger [Wed, 10 May 2023 04:57:57 +0000 (22:57 -0600)]
build: split version and release in configure
Update configure.ac to separate Version from Release if there is
a '-' in version.h::E2FSPROGS_VERSION (e.g. "1.46.6-rc1").
Otherwise, the '-' in the version can make RPM building unhappy.
Simplify the generation of E2FSPROGS_VERESION, E2FSPROGS_DATE and
E2FSPROGS_DAY to avoid multiple grep/awk/sed/tr stages.
Dmitry Chestnykh [Sat, 25 Nov 2023 11:25:55 +0000 (14:25 +0300)]
mke2fs: Add root_perms extended mke2fs option.
This options allows user to specify custom root dir
permissions at FS creation time. If no perms are specified
then the root dir permissions would be set to default.
Steven Luo [Thu, 23 Nov 2023 23:33:37 +0000 (15:33 -0800)]
fuse2fs: respect requested mode in mkdir
At the moment, op_mkdir() ORs the requested mode with fs->umask, which
results in the group/other write permission bits always being cleared
regardless of what the creating process requested. Instead, leave the
requested mode alone so that the resulting directory has the permssions
the creator expects.
Theodore Ts'o [Fri, 25 Aug 2023 21:28:01 +0000 (17:28 -0400)]
libext2fs: don't truncate the orphan file inode if it is newly allocated
In ext2fs_create_orphan_file(), don't try truncating inode for the
orphan file if ext2fs_create_orphan_file() allocated the inode. This
avoids problems where the newly allocated inode in the inode table
might contain garbage; if the metadata checksum feature is enabled,
this will generally result in the function failing with a checksum
invalid error, but this can cause mke2fs (which calls
ext2fs_create_orphan_file) to fail.
Eric Whitney [Fri, 21 Jul 2023 18:55:06 +0000 (14:55 -0400)]
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.
Theodore Ts'o [Tue, 8 Aug 2023 19:50:42 +0000 (15:50 -0400)]
debian: add missing copyright information
When the package-specific copyright information was removed, it
resulted in some information being lost. It probably makes sence to
have all of the licensing information in a single file, so add it back
to the debian/copyright file.
Theodore Ts'o [Thu, 15 Jun 2023 04:17:01 +0000 (00:17 -0400)]
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.
Theodore Ts'o [Wed, 14 Jun 2023 18:44:19 +0000 (14:44 -0400)]
e2fsck: fix handling of a invalid symlink in an inline_data directory
If there is an inline directory that contains a directory entry to an
invalid symlink, and that invalid symlink is the portion of the inline
directory stored in an xattr portion of the inode, this can result in
a buffer overrun.
When check_dir_block() is handling the in-xattr portion of the inline
directory, it sets the buf pointer to the beginning of that part of
the inline directory. This results in the scratch buffer passed to
e2fsck_process_bad_inode() to incorrect, resulting in a buffer overrun
if e2fsck_pass1_check_symlink() needs to read the symlink target (when
the symlink is too long to fit in the i_blocks[] space).
This commit fixes this by using the original cd->buf instead of buf,
since it can get modified when handling inline directories.
Fixes: 0ac4b3973f31 ("e2fsck: inspect inline dir data as two directory blocks") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Wed, 31 May 2023 16:11:53 +0000 (12:11 -0400)]
libsupport: fix function prototype for quota_write_inode()
Commit 2d2d799c7261 ("Clean up codes for adding new quota type")
changed the second paramter of quota_write_inode() from taking a
single quota type to taking a logical OR of (1 << quota_types).
The one thing this commit didn't change was the function prototype for
quota_write_inode() in the header file from an enum to an unsigned
int. Most C compilers don't seem to mind, and omission is mostly
harmless. However, mingw64 does issue a warning which gets promoted
to an error.
Fixes: 2d2d799c7261 ("Clean up codes for adding new quota type") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Eric Biggers [Wed, 22 Mar 2023 03:29:45 +0000 (20:29 -0700)]
ci.yml: test cross-compiling for Android
Add jobs that cross-compile e2fsprogs for Android using the Android NDK.
These use the autotools-based build system, so they're a bit different
from the actual Android builds, but they should still be useful.
Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Eric Biggers [Wed, 22 Mar 2023 03:29:44 +0000 (20:29 -0700)]
e2freefrag: don't use linux/fsmap.h when fsmap_sizeof() is missing
Work around an issue with the Android NDK where its copy of
linux/fsmap.h is missing the inline functions fsmap_sizeof() and
fsmap_advance(). This was causing an error when building e2fsprogs
using the Android NDK, using the autotools-based build system.
Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix two compiler warnings on 32-bit platforms that have mallinfo() but
not mallinfo2(). These showed up when building e2fsprogs for armv7a or
i686 Android using the Android NDK, targeting Android API level 32 or
lower and using the autotools-based build system.
Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>