[Mod] First commit

This commit is contained in:
2022-10-31 22:18:58 +08:00
commit 1c8a3d9709
13090 changed files with 526733 additions and 0 deletions

View File

@ -0,0 +1,59 @@
From ab51d587bb9b229b1fade1afd02e1574c1ba5c76 Mon Sep 17 00:00:00 2001
From: Lukas Czerner <lczerner@redhat.com>
Date: Thu, 21 Apr 2022 19:31:48 +0200
Subject: libext2fs: add sanity check to extent manipulation
It is possible to have a corrupted extent tree in such a way that a leaf
node contains zero extents in it. Currently if that happens and we try
to traverse the tree we can end up accessing wrong data, or possibly
even uninitialized memory. Make sure we don't do that.
Additionally make sure that we have a sane number of bytes passed to
memmove() in ext2fs_extent_delete().
Note that e2fsck is currently unable to spot and fix such corruption in
pass1.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Nils Bars <nils_bars@t-online.de>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2068113
Addresses: CVE-2022-1304
Addresses-Debian-Bug: #1010263
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
[Retrieved from:
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?h=maint&id=ab51d587bb9b229b1fade1afd02e1574c1ba5c76]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
lib/ext2fs/extent.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index b324c7b0..1a206a16 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -495,6 +495,10 @@ retry:
ext2fs_le16_to_cpu(eh->eh_entries);
newpath->max_entries = ext2fs_le16_to_cpu(eh->eh_max);
+ /* Make sure there is at least one extent present */
+ if (newpath->left <= 0)
+ return EXT2_ET_EXTENT_NO_DOWN;
+
if (path->left > 0) {
ix++;
newpath->end_blk = ext2fs_le32_to_cpu(ix->ei_block);
@@ -1630,6 +1634,10 @@ errcode_t ext2fs_extent_delete(ext2_extent_handle_t handle, int flags)
cp = path->curr;
+ /* Sanity check before memmove() */
+ if (path->left < 0)
+ return EXT2_ET_EXTENT_LEAF_BAD;
+
if (path->left) {
memmove(cp, cp + sizeof(struct ext3_extent_idx),
path->left * sizeof(struct ext3_extent_idx));
--
cgit

View File

@ -0,0 +1,82 @@
menuconfig BR2_PACKAGE_E2FSPROGS
bool "e2fsprogs"
depends on BR2_USE_MMU # util-linux/libblkid
select BR2_PACKAGE_UTIL_LINUX
select BR2_PACKAGE_UTIL_LINUX_LIBBLKID
select BR2_PACKAGE_UTIL_LINUX_LIBUUID
help
The EXT2 file system utilities.
The following programs are always built and installed:
badblocks chattr debugfs dumpe2fs e2freefrag e2fsck e2image
e2undo e4crypt e4defrag filefrag fsck fuse2fs logsave lsattr
mke2fs mklost+found resize2fs tune2fs
The uuid utilities (uuidd, uuidgen) are not built. Use the
ones from util-linux, instead.
Other programs can be selected individually.
http://e2fsprogs.sourceforge.net
if BR2_PACKAGE_E2FSPROGS
config BR2_PACKAGE_E2FSPROGS_DEBUGFS
bool "debugfs"
help
ext2/ext3/ext4 file system debugger
config BR2_PACKAGE_E2FSPROGS_E2IMAGE
bool "e2image"
help
Save critical ext2/ext3/ext4 filesystem metadata to a file
config BR2_PACKAGE_E2FSPROGS_E2SCRUB
bool "e2scrub"
depends on BR2_PACKAGE_BASH # runtime
depends on BR2_PACKAGE_COREUTILS # runtime
depends on BR2_PACKAGE_LVM2 # runtime
depends on BR2_PACKAGE_UTIL_LINUX # runtime
help
Check the contents of a mounted ext[234] filesystem
comment "e2scrub needs bash, coreutils, lvm2, and util-linux"
depends on !BR2_PACKAGE_BASH || !BR2_PACKAGE_COREUTILS \
|| !BR2_PACKAGE_LVM2 || !BR2_PACKAGE_UTIL_LINUX
config BR2_PACKAGE_E2FSPROGS_E4DEFRAG
bool "e4defrag"
depends on !BR2_nios2 # fallocate not implemented
depends on !BR2_TOOLCHAIN_USES_UCLIBC # sync_file_range not impl
help
Online defragmenter for ext4 filesystem
comment "e4defrag needs a glibc or musl toolchain"
depends on !BR2_nios2
depends on BR2_TOOLCHAIN_USES_UCLIBC
config BR2_PACKAGE_E2FSPROGS_FSCK
bool "fsck"
default y
depends on !BR2_PACKAGE_UTIL_LINUX_FSCK
help
Check and repair a Linux file system. This is a wrapper around
the filesystem-specific fsck tools.
config BR2_PACKAGE_E2FSPROGS_FUSE2FS
bool "fuse2fs"
depends on !BR2_STATIC_LIBS # libfuse
depends on BR2_TOOLCHAIN_HAS_THREADS # libfuse
select BR2_PACKAGE_LIBFUSE
help
FUSE file system client for ext2/ext3/ext4 file systems
comment "fuse2fs needs a toolchain w/ threads, dynamic library"
depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS
config BR2_PACKAGE_E2FSPROGS_RESIZE2FS
bool "resize2fs"
help
ext2/ext3/ext4 file system resizer
endif

View File

@ -0,0 +1,7 @@
config BR2_PACKAGE_HOST_E2FSPROGS
bool "host e2fsprogs"
select BR2_PACKAGE_HOST_UTIL_LINUX
help
The EXT2/3/4 file system utilities.
http://e2fsprogs.sourceforge.net

View File

@ -0,0 +1,6 @@
# From https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.46.5/sha256sums.asc
sha256 2f16c9176704cf645dc69d5b15ff704ae722d665df38b2ed3cfc249757d8d81e e2fsprogs-1.46.5.tar.xz
# Locally calculated
sha256 5da5ef153e559c1d990d4c3eedbedd4442db892d37eae1f35fff069de8ec9020 NOTICE
sha256 032989b508f1a72ebee5b3417e55d06d473f9ee203e45ab11864a7e49cdec63d lib/ss/mit-sipb-copyright.h
sha256 47182fe6631a32f271a15bbe210751b3825b7199f588879aac7d4804fc8b4b8f lib/et/internal.h

View File

@ -0,0 +1,103 @@
################################################################################
#
# e2fsprogs
#
################################################################################
E2FSPROGS_VERSION = 1.46.5
E2FSPROGS_SOURCE = e2fsprogs-$(E2FSPROGS_VERSION).tar.xz
E2FSPROGS_SITE = $(BR2_KERNEL_MIRROR)/linux/kernel/people/tytso/e2fsprogs/v$(E2FSPROGS_VERSION)
E2FSPROGS_LICENSE = GPL-2.0, MIT-like with advertising clause (libss and libet)
E2FSPROGS_LICENSE_FILES = NOTICE lib/ss/mit-sipb-copyright.h lib/et/internal.h
E2FSPROGS_CPE_ID_VENDOR = e2fsprogs_project
E2FSPROGS_INSTALL_STAGING = YES
# 0001-libext2fs-add-sanity-check-to-extent-manipulation.patch
E2FSPROGS_IGNORE_CVES += CVE-2022-1304
# Use libblkid and libuuid from util-linux for host and target packages.
# This prevents overriding them with e2fsprogs' ones, which may cause
# problems for other packages.
E2FSPROGS_DEPENDENCIES = host-pkgconf util-linux
HOST_E2FSPROGS_DEPENDENCIES = host-pkgconf host-util-linux
E2FSPROGS_SELINUX_MODULES = fstools
# e4defrag doesn't build on older systems like RHEL5.x, and we don't
# need it on the host anyway.
# Disable fuse2fs as well to avoid carrying over deps, and it's unused
HOST_E2FSPROGS_CONF_OPTS = \
--disable-defrag \
--disable-e2initrd-helper \
--disable-fuse2fs \
--disable-fsck \
--disable-libblkid \
--disable-libuuid \
--disable-testio-debug \
--enable-symlink-install \
--enable-elf-shlibs \
--with-crond-dir=no \
--with-udev-rules-dir=no \
--with-systemd-unit-dir=no
# Set the binary directories to "/bin" and "/sbin", as busybox does,
# so that we do not end up with two versions of e2fs tools.
E2FSPROGS_CONF_OPTS = \
--bindir=/bin \
--sbindir=/sbin \
$(if $(BR2_STATIC_LIBS),--disable-elf-shlibs,--enable-elf-shlibs) \
$(if $(BR2_PACKAGE_E2FSPROGS_DEBUGFS),--enable-debugfs,--disable-debugfs) \
$(if $(BR2_PACKAGE_E2FSPROGS_E2IMAGE),--enable-imager,--disable-imager) \
$(if $(BR2_PACKAGE_E2FSPROGS_E4DEFRAG),--enable-defrag,--disable-defrag) \
$(if $(BR2_PACKAGE_E2FSPROGS_FSCK),--enable-fsck,--disable-fsck) \
$(if $(BR2_PACKAGE_E2FSPROGS_RESIZE2FS),--enable-resizer,--disable-resizer) \
--disable-uuidd \
--disable-libblkid \
--disable-libuuid \
--disable-e2initrd-helper \
--disable-testio-debug \
--disable-rpath \
--enable-symlink-install
ifeq ($(BR2_PACKAGE_E2FSPROGS_FUSE2FS),y)
E2FSPROGS_CONF_OPTS += --enable-fuse2fs
E2FSPROGS_DEPENDENCIES += libfuse
else
E2FSPROGS_CONF_OPTS += --disable-fuse2fs
endif
ifeq ($(BR2_nios2),y)
E2FSPROGS_CONF_ENV += ac_cv_func_fallocate=no
endif
E2FSPROGS_CONF_ENV += ac_cv_path_LDCONFIG=true
HOST_E2FSPROGS_CONF_ENV += ac_cv_path_LDCONFIG=true
E2FSPROGS_INSTALL_STAGING_OPTS = \
DESTDIR=$(STAGING_DIR) \
install-libs
# e2scrub has no associated --enable/disable option
ifneq ($(BR2_PACKAGE_E2FSPROGS_E2SCRUB),y)
E2FSPROGS_MAKE_OPTS += E2SCRUB_DIR=
endif
E2FSPROGS_INSTALL_TARGET_OPTS = \
$(E2FSPROGS_MAKE_OPTS) \
DESTDIR=$(TARGET_DIR) \
install
# Package does not build in parallel due to improper make rules
define HOST_E2FSPROGS_INSTALL_CMDS
$(HOST_MAKE_ENV) $(MAKE1) -C $(@D) install install-libs
endef
# Remove compile_et which raises a build failure with samba4
define HOST_E2FSPROGS_REMOVE_COMPILE_ET
$(RM) $(HOST_DIR)/bin/compile_et
endef
HOST_E2FSPROGS_POST_INSTALL_HOOKS += HOST_E2FSPROGS_REMOVE_COMPILE_ET
$(eval $(autotools-package))
$(eval $(host-autotools-package))