Lukas Czerner [Tue, 14 Aug 2018 14:37:53 +0000 (16:37 +0200)]
libe2p: avoid segfault when s_nr_users is too high
Currently in e2fsprogs tools it's possible to access out of bounds
memory when reading list of ids sharing a journal log
(journal_superblock_t->s_users[]) in case where s_nr_users is too high.
This is because we never check whether the s_nr_users fits into the
restriction of JFS_USERS_MAX. Fix it by checking that nr_users is not
bigger than JFS_USERS_MAX and error out when possiblem.
Also add test for dumpe2fs. The rest would require involving external
journal which is not possible to test with e2fsprogs test suite at the
moment.
Darrick J. Wong [Tue, 28 Aug 2018 23:38:07 +0000 (16:38 -0700)]
libext2fs: try to always use PUNCH_HOLE for unix_discard
Now that block devices support PUNCH_HOLE via fallocate, refactor the
unix_discard code into a helper that will always try to use it. For
block devices we can fall back to BLKDISCARD, but we prefer to use
fallocate because it will always invalidate the page cache of the zeroed
region.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Darrick J. Wong [Tue, 28 Aug 2018 23:38:00 +0000 (16:38 -0700)]
libext2fs: use ZERO_RANGE before PUNCH_HOLE in unix_zeroout
In unix_zeroout() for files, we should try a ZERO_RANGE before we try
PUNCH_HOLE because the former will not cause us to lose preallocated
blocks. Since block devices have supported fallocate for a few years
now, refactor the fallocate calls into a helper and call it from either
case.
Reported-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Fri, 24 Aug 2018 21:12:20 +0000 (17:12 -0400)]
For --enable-subset, change "make install" so it implies "make install-libs"
The e2fsprogs-libs-1.44.x.tar.gz subset distribution had a hack so
that "make install" would install the libraries via an implied "make
install-libs" --- since after all the tarball had was just the
libraries.
This commit makes "make install" behave the same was as the
e2fsprogs-libs distribution in the case of "configure --enable-subset"
Theodore Ts'o [Wed, 22 Aug 2018 20:33:10 +0000 (16:33 -0400)]
debian: remove hard-coded dependency for libss2 in e2fsprogs.shlibs.local
The hard-coded override is very old, and isn't necessary --- in fact,
it's actively harmful because we are using one or two symbols that
were added to libss2 after e2fsprogs 1.34. So remove it.
Eric Biggers [Tue, 21 Aug 2018 17:59:37 +0000 (10:59 -0700)]
e2fsck: allow verity files to have initialized blocks past i_size
Since ext4 verity is going to be an RO_COMPAT feature rather than an
INCOMPAT one, the on-disk i_size of verity inodes needs to be the data
size rather than the full size. Consequently, verity inodes will have
initialized blocks past i_size, containing the Merkle tree and other
verity metadata. So e2fsck must not fix the i_size of such inodes as it
normally would.
Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Eric Biggers [Tue, 21 Aug 2018 00:15:52 +0000 (17:15 -0700)]
libext2fs: add verity flag to EXT2_LIB_FEATURE_RO_COMPAT_SUPP
The new ro_compat filesystem feature flag for fs-verity was added to
EXT2_FEATURE_RO_COMPAT_SUPP, but that's not actually used by e2fsprogs
itself. So contrary to the v1.44.4 release notes, 'mke2fs -O verity'
doesn't actually work, nor does e2fsck allow the filesystem to have the
verity feature. Fix it by adding the flag to the correct place
(EXT2_LIB_FEATURE_RO_COMPAT_SUPP) too.
Fixes: faae7aa00df0 ("Reserve codepoints for the fsverity feature.") Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Upendra [Thu, 1 Mar 2018 08:15:48 +0000 (17:15 +0900)]
AOSP: blkid: Correct the label name for exfat
Volume label name is 16 bit unicode string according to spec.
Currently blkid labels the device without converting it to
utf-8 chars due to which incorrect label is displayed.
Theodore Ts'o [Sat, 18 Aug 2018 15:19:25 +0000 (11:19 -0400)]
Drop subset tarball and replace it with "configure --enable-subset"
There's no point creating two separate tarfiles. It's not clear
anyone was actually using the subset tarball --- and if they are, they
can replace it by the full source distribution and using the
--enable-subset option.
Theodore Ts'o [Sat, 18 Aug 2018 13:55:26 +0000 (09:55 -0400)]
Remove obsolete files from the repository
They are removed when we generate the tarball, and they serve no
useful purpose, so let's remove them. This will be help us to create
the tarball using git archive more easily.
Theodore Ts'o [Sat, 18 Aug 2018 04:06:40 +0000 (00:06 -0400)]
gen-tarball: handle symlinks correctly in the created the tar file
Now that we use a symlink for the top-level RELEASE-NOTES file, the
previous strategy of using a symlink to force the prefix in the tar
file and then using tar -h won't work. So change how we generate the
tar file to take advantage of GNU tar's --transform option.
Theodore Ts'o [Sat, 18 Aug 2018 02:26:24 +0000 (22:26 -0400)]
configure: don't enable LTO by default
Not all compilers (or versions of compilers) use the same LTO options
or behave the same way with LTO. In particular, using clang and the
current LTO options cause the build to fail. We should probably fix
up the configure script to handle Clang and LTO, but for now, we won't
enable LTO unless the user explicitly passes --enable-lto to the
configure script.
Theodore Ts'o [Sun, 12 Aug 2018 04:30:07 +0000 (00:30 -0400)]
debian: use debhelper compat level 11 with a fallback to compat level 9
The dh_installsystemd command is only available with Debhelper v11 and
higher. So explicitly declare that we need debhelper 11, and create a
fallback for debhelper compat level 9 (so we can easily backport to
Debian Stretch and Ubuntu 16.04).
Lukas Czerner [Wed, 8 Aug 2018 11:52:56 +0000 (13:52 +0200)]
e2fsck: remove resize inode if both resize_inode and meta_bg are enabled
Previous e2fsprogs versions allowed to create a file system with both
resize_inode and meta_bg enabled. This was fixed by upstream commit 42e77d5d ("libext2fs: don't create filesystems with meta_bg and resize_inode")
However e2fsck still does not recognize the conflict and will attempt to
clear and recreate resize_inode if it's corrupted due to this incompatible
feature combination, though it will create it in the same wrong layout.
Fix it by teaching e2fsck to recognize resize_inode and meta_bg
conflict and fixing it by disabling and clearing resize inode.
Theodore Ts'o [Thu, 9 Aug 2018 01:33:27 +0000 (21:33 -0400)]
MCONFIG: move SANITIZER_CFLAGS out of CLFAGS
CFLAGS is supposed to be something that can be overridden by the
developer. So extra stuff like $(SANITIZER_CFLAGS) should not be
defined there, but rather in ALL_CFLAGS.
Theodore Ts'o [Thu, 9 Aug 2018 01:23:59 +0000 (21:23 -0400)]
e2fsck: fix LTO type warnings
The jfs_user.h, which is used by the journal functions didn't include
config.h before including e2fsck.h. This caused the e2fsck structure
to be different compared how it's compiled for the other e2fsck source
files.
Theodore Ts'o [Wed, 8 Aug 2018 17:53:11 +0000 (13:53 -0400)]
libext2fs: revamp bitmap types to fix LTO warnings
We play games with pointers to incomplete types to handle subclassing
using the C language, use the first four bytes (the magic number)
field to disambiguate between different subclasses. The way we were
doing it before, we relied defining the structure differently
depending on the C file implementing different backend subclasses.
This triggers LTO warnings, since it appears (and in fact, we are)
using functions defined with different types than how they were
defined by calling C file.
Fix the LTO warnings by using an explicit base bitmap structure, and
then casting it to the 32-bit or 64-bit variant as needed.
Darrick J. Wong [Sat, 24 Mar 2018 01:57:09 +0000 (18:57 -0700)]
e2scrub: create online fsck tool of sorts
Implement online fsck for ext* filesystems which live on LVM-managed
logical volumes. The basic strategy mirrors that of e2croncheck --
create a snapshot, fsck the snapshot, report whatever errors appear,
remove snapshot. Unlike e2croncheck, this utility accepts any LVM
device path, knows about snapshots running out of space, and can call
fstrim having validated that the fs metadata is ok.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
David Anderson [Thu, 12 Jul 2018 23:55:08 +0000 (16:55 -0700)]
AOSP: Update Android.bp files.
debugfs now links to a new libext2_support library, which only includes
cstring.c (Android separates other pieces of libsupport into separate
libraries).
Jaco Kroon [Thu, 2 Aug 2018 18:06:46 +0000 (20:06 +0200)]
debugfs: fix ncheck so it handles hard links correctly
Due to hard links inodes can have multiple names (except for folders),
ncheck should find all of the names (equal to the number of links to the
inodes, directories excepted), not names to the count of the provided
inodes.
Theodore Ts'o [Sun, 5 Aug 2018 01:06:19 +0000 (21:06 -0400)]
debian: stop using symlinks to save space on *-dev packages
Using symlinks to save space on duplicate copies of the
/usr/share/doc/*/changelog.Debian.gz is a bit of a mess, since when
the foo-dev package is removed, the files in /usr/share/doc/libfoo/*
get removed, which means the copyright file gets removed.
So stop doing this altogether, and set up maintainer scripts to clean
up the mess so that the symlinks are removed when the packages get
upgraded.
resize2fs: Remove the real kilobytes rant from man page
Remove the rant about the "real" kilobytes from the man page and just
make it more clear that the suffixed units are representing power-of-two
units as we do in mke2fs man page. Also add terabytes to the list.
Li Dongyang [Sat, 14 Jul 2018 00:42:48 +0000 (18:42 -0600)]
Fix compile error and warnings for old gcc versions
-Wimplicit-fallthrough option was added in gcc7 and
-Wpedantic was added in gcc4.8, while #pragma GCC diagnostic
support was not available until gcc4.6
We got following warnings:
../lib/ext2fs/fiemap.h:35: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
../lib/ext2fs/fiemap.h:36: warning: unknown option after ‘#pragma GCC diagnostic’ kind
../lib/ext2fs/fiemap.h:38: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
and error:
filefrag.c: In function ‘main’:
filefrag.c:577: error: #pragma GCC diagnostic not allowed inside functions
filefrag.c:578: error: #pragma GCC diagnostic not allowed inside functions
filefrag.c:595: error: #pragma GCC diagnostic not allowed inside functions
when compiling latest e2fsprogs with a gcc older than 4.6
e.g. on CentOS 6.9
Signed-off-by: Li Dongyang <dongyangli@ddn.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
libext2fs: call fsync(2) to clear stale errors for a new a unix I/O channel
Newer versions of Linux will retain errors and allow them to be
returned by fsync() or close(), even if the error happened before the
file descriptor was opened. This was to accomodate Postgres's
"interesting" method of error collection.
Unfortunately, for e2fsck, we never want to see stale errors, as this
can cause xfstests (such generic/347) to fail with a false positive.
e2fsck: fix kernel compat functions to use kernel error return conventions
Fix journal_bmap() and sync_blockdev() to use the kernel error
convetions (e.g., -EIO instead of EIO) since they are called by
reovery.c, which is shared userspace / kernel code.
Without this, e2fsck might print an error message like this:
/sbin/e2fsck: Unknown code ____ 251 while recovering journal of /dev/mapper/thin-vol
instead of what it should have printed which was this:
/sbin/e2fsck: Input/output error while recovering journal of /dev/mapper/thin-vol
Andreas Dilger [Mon, 2 Jul 2018 21:06:32 +0000 (17:06 -0400)]
tests: make generated test scripts read-only
Make generated test scripts read-only, to avoid errors by developers
editing the generated test scripts and then having them accidentally
clobbered when "make" is run again.
Change-Id: I60d417b816b7c559b5e05baf4167fc2cf2a871cf Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Theodore Ts'o [Fri, 29 Jun 2018 15:35:58 +0000 (11:35 -0400)]
e2fsck: if user declines to fix s_inodes_acount, abort
A recent commit, d74eb7ef: "e2fsck: handle s_inodes_count corruption
properly" tries to fix s_inodes_count. However, if the user declines
to fix the invalid s_inodes_count, e2fsck needs to abort since
otherwise we can crash due to the insane s_inodes_count.
Theodore Ts'o [Thu, 28 Jun 2018 15:10:58 +0000 (11:10 -0400)]
e2fsck: fix hang in readahead code if last block in fs is metadata
If the last block the file system is metadata (very rare, but it can
happen, especially if e2fsck needs to relocate a bitmap block), e2fsck
will hang while trying to do readahead.
Theodore Ts'o [Tue, 26 Jun 2018 19:21:28 +0000 (15:21 -0400)]
tests, mke2fs: add option to suppress xattr copying to fix f_extent_htree
If the developer is running with SELinux enabled on /tmp, the
f_extent_htree regression test will fail because mke2fs by default
copies the extended attributes into the newly created file system (if
a directory hierarchy is specified via the -d option).
Fix this by adding a new extended option to mke2fs, -E no_copy_xattrs
and using it in f_extent_htree's test script.
Theodore Ts'o [Tue, 26 Jun 2018 13:59:19 +0000 (09:59 -0400)]
tests: explicitly force resize2fs's use of lazy (or not)
Resize2fs will not enable lazy_itable if the kernel apparently does
not support that feature. This will cause spurious test failures when
the tests are running on such a system (or where sysfs is not
mounted).
So for the purposes of the regression test we need to force the use of
lazy_itable so that the results conform to expected golden output.
Theodore Ts'o [Tue, 26 Jun 2018 13:02:46 +0000 (09:02 -0400)]
debugfs: fix mknod command on some 32-bit platforms due to LFS
On some platforms the layout of struct stat changes if
_FILE_OFFSET_BITS is set to 64 (which force the use of 64-bit types
and 64-bit variants for system calls such as stat, lseek, etc.)
This is not true (mercifully) on i386, but it is true for the 32-bit
mips platform on Linux. This caused debugfs's mknod command to fail,
since it used struct stat to pass the desired st_mode and st_rdev
fields for the to-be-created device file or FIFO, and this would be
different for create_inode.c and debugfs.c.
Linking together different object files together compiled with
different values of _FILE_OFFSET_BITS is perilous, but for now, let's
fix the specific problem by passing the two fields in the stat
structure that we really care about. This fixes two regression tests
on the 32-bit MIPS platform: d_special_files and r_move_itable.