Index: head/sysutils/e2fsprogs/Makefile =================================================================== --- head/sysutils/e2fsprogs/Makefile (revision 469629) +++ head/sysutils/e2fsprogs/Makefile (revision 469630) @@ -1,253 +1,253 @@ # Created by: Maxim Sobolev # $FreeBSD$ PORTNAME= e2fsprogs PORTVERSION= 1.44.1 -PORTREVISION?= 0 +PORTREVISION?= 1 CATEGORIES?= sysutils MASTER_SITES= KERNEL_ORG/linux/kernel/people/tytso/${PORTNAME}/v${PORTVERSION} MAINTAINER?= mandree@FreeBSD.org COMMENT?= Utilities & library to manipulate ext2/3/4 filesystems LICENSE?= GPLv2+ .if !defined(_no_license_file) LICENSE_FILE?= ${WRKSRC}/NOTICE .endif LICENSE_DISTFILES_GPLv2= ${DISTNAME}${EXTRACT_SUFX} PORTSCOUT= ignore # cannot handle the version in the directory .if !defined(MASTERDIR) BROKEN_aarch64= fails to link: missing sbrk BROKEN_armv6= fails to build: Tests failed: f_pre_1970_date_encoding BROKEN_armv7= fails to build: Tests failed: f_pre_1970_date_encoding .endif USES= cpe gmake makeinfo pkgconfig tar:xz CPE_VENDOR= e2fsprogs_project USE_CSTD= gnu99 # this seems a bit redundant to the --rpath below, but # the latter should be more robust in case someone needs # to deal with the file systems from a system not yet fully booted. .if !defined(PKGNAMESUFFIX) USE_LDCONFIG= ${PREFIX}/lib/e2fsprogs .endif GNU_CONFIGURE= yes LLD_UNSAFE= yes CONFIGURE_ARGS?=--disable-fsck \ --disable-e2initrd-helper \ --disable-libuuid \ --disable-uuidd \ --enable-libblkid \ --enable-elf-shlibs \ --libdir='${PREFIX}/lib/e2fsprogs/' \ --includedir='${PREFIX}/include/e2fsprogs/' \ --with-root-prefix='${PREFIX}' \ --without-included-gettext \ LDFLAGS='${LDFLAGS} -L${LOCALBASE}/lib -Wl,--rpath -Wl,${LOCALBASE}/lib/e2fsprogs' CPPFLAGS+= -I${WRKSRC}/lib -I${LOCALBASE}/include # -D_EXT2_USE_C_VERSIONS MAKE_ARGS+= pkgconfigdir='${PREFIX}/libdata/pkgconfig' MAKE_ENV+= CHECK_CMD=@true .if !defined(MASTERDIR) INSTALL_TARGET= install install-libs OPTIONS_DEFINE= DOCS NLS FUSEFS PARALLELTESTS OPTIONS_EXCLUDE+= EXAMPLES OPTIONS_SUB= yes OPTIONS_SINGLE= SELFTEST OPTIONS_SINGLE_SELFTEST= NOTESTS SMALLTESTS ALLTESTS OPTIONS_DEFAULT= SMALLTESTS FUSEFS_DESC= Build user-land ext2/3/4 FUSE module (slow!) SELFTEST_DESC= Choose which set of self-tests to run NOTESTS_DESC= Do not run any self-tests (Tier-1, DISCOURAGED) SMALLTESTS_DESC=Run tests that need <500 MB disk space (DEFAULT) ALLTESTS_DESC= Run most self-tests (needs more RAM/disk space) PARALLELTESTS_DESC= Parallelize self-tests (needs more disk space) FUSEFS_CONFIGURE_ENABLE= fuse2fs BUILD_DEPENDS+= gdd:sysutils/coreutils LIB_DEPENDS+= libblkid.so:misc/e2fsprogs-libblkid LIB_DEPENDS+= libss.so:devel/e2fsprogs-libss LIB_DEPENDS+= libuuid.so:misc/e2fsprogs-libuuid PORTDOCS= NOTICE README RELEASE-NOTES SUBMITTING-PATCHES .endif PKGDEINSTALL= ${PKGINSTALL} MAKE_ARGS+= V=1 .include .if ${PORT_OPTIONS:MFUSEFS} USES+= fuse .endif .if ${PORT_OPTIONS:MNLS} USES+= gettext iconv:build .endif .if empty(PORT_OPTIONS:MNOTESTS) && ${MASTERDIR} == ${.CURDIR} USES+= perl5 USE_PERL5= build .endif .include .if ${PORT_OPTIONS:MNLS} . if empty(ICONV_LIB) libintl= ${LOCALBASE}/lib/libintl.a . else libintl= ${LOCALBASE}/lib/libintl.a ${LOCALBASE}/lib/libiconv.a . endif .else CONFIGURE_ARGS+=--disable-nls libintl= .endif # d_fallocate_blkmap appears to fail on some systems for unknown reasons. post-patch:: # don't build/install libext2fs.info @${REINPLACE_CMD} -e 's/ install-doc-libs$$//' ${WRKSRC}/Makefile.in @${REINPLACE_CMD} -E -e 's/md5sum ([^ ]*)/printf "%s %s\\n" $$(md5 -q \1) \1/' \ -e "s/ == 0/ = 0/" -e "s/tar x$$/tar xf -/" -e "s/\/gdd/" \ ${WRKSRC}/tests/[a-z]_*/script @${REINPLACE_CMD} -e 's///' ${WRKSRC}/*/*.c .if empty(PORT_OPTIONS:MALLTESTS) .for i in \ d_fallocate_blkmap \ f_baddir \ f_bbfile \ f_convert_bmap \ f_detect_junk \ f_inode_ea_collision \ f_lpffile \ f_no_cache_corrupt_inode \ f_opt_extent \ j_corrupt_descr_csum \ m_bigjournal \ m_hugefile_slack \ m_offset \ m_raid_opt \ r_32to64bit \ r_32to64bit_expand_full \ r_32to64bit_meta \ r_32to64bit_move_itable \ r_64to32bit \ r_64to32bit_meta \ r_expand_full \ r_min_itable \ t_change_uuid_mounted \ t_dangerous \ t_disable_changed_csum_seed_mounted \ t_disable_mcsum \ t_disable_mcsum_noinitbg \ t_disable_mcsum_yesinitbg \ t_enable_mcsum \ t_enable_mcsum_initbg \ t_iexpand_full \ t_iexpand_mcsum \ t_uninit_bg_rm \ u_dryrun \ u_mke2fs_opt_offset @${MV} ${WRKSRC}/tests/${i} ${WRKSRC}/tests/disabled_test-${i} .endfor .endif # Master port stuff that is not to be seen by the slave ports. .if ${MASTERDIR} == ${.CURDIR} # NOTE: The previous .if block goes all the way to the end of the file. .if !empty(PORT_OPTIONS:MNOTESTS) && (${OPSYS} == FreeBSD) && (${OSVERSION} >= 1200000 || ((${ARCH} != i386) && (${ARCH} != amd64))) BROKEN= it was not tested on your system by the maintainer; you must run self-tests .endif pre-build: # fix up Makefile ordering for parallel builds cd ${WRKSRC}/lib/et && ${DO_MAKE_BUILD} compile_et cd ${WRKSRC}/lib/support && ${DO_MAKE_BUILD} prof_err.h .if ${PORT_OPTIONS:MPARALLELTESTS} _CHECK_JOBS=${_MAKE_JOBS} .else _CHECK_JOBS= .endif .if !defined(TMPDIR) _checkaddargs=TMPDIR=${WRKDIR}/tmp .endif post-build: # Relink e2fsck statically - We need to make sure that tools for the root file # system are statically linked against anything that is outside the root fs, # else we're in trouble if e2fsck is needed for boot: # (we don't use e2fsck.static, since we can link libc.so dynamically) cd ${WRKSRC}/e2fsck && ${RM} -f e2fsck \ && ${MAKE_CMD} e2fsck V=1 \ LIBS="../lib/libsupport.a ../lib/libext2fs.a ../lib/libcom_err.a \ ${LOCALBASE}/lib/libblkid.a ${LOCALBASE}/lib/libuuid.a ${libintl} ../lib/libe2p.a" \ LIBMAGIC=/usr/lib/libmagic.a\ -lz # Regression check: avoid a port (not upstream!) regression from 1.40.5, # check that e2fsck isn't dynalinked against anything but libc.so: @${ECHO_CMD} -n "===> checking that e2fsck depends on no shared objects outside /lib: " @a="$$(ldd ${WRKSRC}/e2fsck/e2fsck 2>/dev/null \ | ${GREP} -v 'not a dynamic executable' \ | ${GREP} '=>' \ | ${AWK} '{print $$3;}' \ | ${EGREP} -v '^/lib/lib.*\.so\.' || :)"; \ if test "x$$a" = "x" ; then echo 'PASS' ; else \ echo 'FAIL' ; echo '===> e2fsck depends on:' ; echo "$$a" ; exit 1 ; fi # Update translation binary files .if ${PORT_OPTIONS:MNLS} cd ${WRKSRC}/po && ${MAKE_CMD} update-gmo .endif # Build fsck(8) wrapper ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -s ${LIBS} \ -o ${WRKSRC}/fsck_ext2fs ${FILESDIR}/fsck_ext2fs.c # While the ${MAKE} check can take a minute on an end user's system, the # correctness of tools such as e2fsck is critical to the health of the # file systems. The upstream is not using any *BSD as his development # system, and therefore let's exercise due diligence in running the self- # test on each and every system and not just package building hosts. # There have been subtle failures induced by Linux-isms in the past. # -- Matthias Andree, package maintainer, 2007-09-18 .if empty(PORT_OPTIONS:MNOTESTS) @${ECHO_CMD} '===> Running e2fsprogs self-test suite' # do not add -j options unconditionally to ${MAKE_CMD} below, this might break # due to excessive disk space use. cd ${WRKSRC}/tests && ulimit -t 60 && ${MKDIR} ${WRKDIR}/tmp && ${SETENV} e2fsprogs_inhibit_SIGINFO=1 BLKID_FILE=${WRKDIR}/tmp/blkid.tab ${MAKE_CMD} check ${_CHECK_JOBS} ${_checkaddargs} \ || { head -n30000 ${WRKSRC}/tests/*.failed 2>/dev/null ; exit 1 ; } .else @${ECHO_CMD} '===> SKIPPING e2fsprogs self-test suite (DISCOURAGED!)' .endif post-install: ${INSTALL_PROGRAM} ${WRKSRC}/fsck_ext2fs ${STAGEDIR}${PREFIX}/sbin/ ${INSTALL_MAN} ${FILESDIR}/fsck_ext2fs.8 ${STAGEDIR}${PREFIX}/man/man8/ .if ${PORT_OPTIONS:MDOCS} ${MKDIR} ${STAGEDIR}${DOCSDIR} .for i in ${PORTDOCS} ${INSTALL_DATA} ${WRKSRC}/${i} ${STAGEDIR}${DOCSDIR} .endfor .endif # remove or relocate files installed by other ports already, or shadowing system files: cd ${STAGEDIR}${PREFIX} && \ ${XARGS} <${FILESDIR}/unwanted ${RM} && \ ${RMDIR} include/e2fsprogs/blkid include/e2fsprogs/ss share/ss ${MV} ${STAGEDIR}${PREFIX}/bin/compile_et ${STAGEDIR}${PREFIX}/bin/e2fsprogs-compile_et ${MV} ${STAGEDIR}${PREFIX}/man/man1/compile_et.1 ${STAGEDIR}${PREFIX}/man/man1/e2fsprogs-compile_et.1 ${MKDIR} ${STAGEDIR}${DATADIR}/et/ ${MV} ${STAGEDIR}${PREFIX}/share/et/* ${STAGEDIR}${DATADIR}/et/ ${REINPLACE_CMD} -e 's}^DIR=.*$$}DIR=${DATADIR}/et}' -i '' ${STAGEDIR}${PREFIX}/bin/e2fsprogs-compile_et ${RMDIR} ${STAGEDIR}${PREFIX}/share/et # # the next line closes .if ${MASTERDIR} == ${.CURDIR} .endif .include Index: head/sysutils/e2fsprogs/files/patch-za =================================================================== --- head/sysutils/e2fsprogs/files/patch-za (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-za (revision 469630) @@ -0,0 +1,34 @@ +From 17a1f2c1929630e3a79e6b98168d56f96acf2e8b Mon Sep 17 00:00:00 2001 +From: Andreas Dilger +Date: Thu, 29 Mar 2018 12:36:54 -0600 +Subject: filefrag: avoid temporary buffer overflow + +If an unknown flag is present in a FIEMAP extent, it is printed as a +hex value into a temporary buffer before adding it to the flags. If +that unknown flag is over 0xfff then it will overflow the temporary +buffer. + +Reported-by: Sarah Liu +Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10335 +Signed-off-by: Andreas Dilger +Signed-off-by: Theodore Ts'o +--- + misc/filefrag.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/filefrag.c b/misc/filefrag.c +index 9c57ab9..dc00393 100644 +--- ./misc/filefrag.c ++++ b/misc/filefrag.c +@@ -179,7 +179,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex, + print_flag(&fe_flags, FIEMAP_EXTENT_SHARED, flags, "shared,"); + /* print any unknown flags as hex values */ + for (mask = 1; fe_flags != 0 && mask != 0; mask <<= 1) { +- char hex[6]; ++ char hex[sizeof(mask) * 2 + 4]; /* 2 chars/byte + 0x, + NUL */ + + if ((fe_flags & mask) == 0) + continue; +-- +cgit v1.1 + Property changes on: head/sysutils/e2fsprogs/files/patch-za ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/e2fsprogs/files/patch-zb =================================================================== --- head/sysutils/e2fsprogs/files/patch-zb (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-zb (revision 469630) @@ -0,0 +1,73 @@ +From 9db53e3fec3413572a2240bd374e76353fab9cbe Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Sat, 7 Apr 2018 00:28:49 -0400 +Subject: libext2fs: add sanity checks for ea_in_inode + +An inode containing the value for an extended attribute (aka an +ea_in_inode) must not have the INLINE_DATA flag and must have the +EA_INODE flag set. Enforcing this prevents e2fsck and debugfs crashes +caused by a maliciously crafted file system containing an inode which +has both the EA_INODE and INLINE_DATA flags set, and where that inode +has an extended attribute whose e_value_inum points to itself. + +Reported-by: Wen Xu +Signed-off-by: Theodore Ts'o +--- + e2fsck/pass1.c | 1 + + lib/ext2fs/ext2_err.et.in | 3 +++ + lib/ext2fs/ext_attr.c | 8 +++++++- + 3 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c +index fccd881..69b3f09 100644 +--- ./e2fsck/pass1.c ++++ b/e2fsck/pass1.c +@@ -1542,6 +1542,7 @@ void e2fsck_pass1(e2fsck_t ctx) + case EXT2_ET_NO_INLINE_DATA: + case EXT2_ET_EXT_ATTR_CSUM_INVALID: + case EXT2_ET_EA_BAD_VALUE_OFFSET: ++ case EXT2_ET_EA_INODE_CORRUPTED: + /* broken EA or no system.data EA; truncate */ + if (fix_problem(ctx, PR_1_INLINE_DATA_NO_ATTR, + &pctx)) { +diff --git a/lib/ext2fs/ext2_err.et.in b/lib/ext2fs/ext2_err.et.in +index ac96964..16abd23 100644 +--- ./lib/ext2fs/ext2_err.et.in ++++ b/lib/ext2fs/ext2_err.et.in +@@ -542,4 +542,7 @@ ec EXT2_ET_CORRUPT_JOURNAL_SB, + ec EXT2_ET_INODE_CORRUPTED, + "Inode is corrupted" + ++ec EXT2_ET_EA_INODE_CORRUPTED, ++ "Inode containing extended attribute value is corrupted" ++ + end +diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c +index 89c5f2c..81b067a 100644 +--- ./lib/ext2fs/ext_attr.c ++++ b/lib/ext2fs/ext_attr.c +@@ -903,6 +903,7 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle, + memcpy(x->value, value_start + entry->e_value_offs, + entry->e_value_size); + } else { ++ struct ext2_inode *ea_inode; + ext2_file_t ea_file; + + if (entry->e_value_offs != 0) +@@ -920,7 +921,12 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle, + if (err) + return err; + +- if (ext2fs_file_get_size(ea_file) != ++ ea_inode = ext2fs_file_get_inode(ea_file); ++ if ((ea_inode->i_flags & EXT4_INLINE_DATA_FL) || ++ !(ea_inode->i_flags & EXT4_EA_INODE_FL) || ++ ea_inode->i_links_count == 0) ++ err = EXT2_ET_EA_INODE_CORRUPTED; ++ else if (ext2fs_file_get_size(ea_file) != + entry->e_value_size) + err = EXT2_ET_EA_BAD_VALUE_SIZE; + else +-- +cgit v1.1 + Property changes on: head/sysutils/e2fsprogs/files/patch-zb ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/e2fsprogs/files/patch-zc =================================================================== --- head/sysutils/e2fsprogs/files/patch-zc (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-zc (revision 469630) @@ -0,0 +1,226 @@ +From bfc1856029ff6851845de27114fea899bbdbccbe Mon Sep 17 00:00:00 2001 +From: Lukas Czerner +Date: Mon, 9 Apr 2018 11:58:15 -0400 +Subject: e2image: fix metadata image handling on big endian systems + +Currently e2image metadata image handling and creating is completely +broken on big endian systems. It just does not care about endianness at +all. This was uncovered With addition of i_bitmaps test, which is the +first test that actually tests e2image metadata image. + +Fix it by making sure that all on-disk metadata that we write and read +to/from the metadata image is properly converted. + +Signed-off-by: Lukas Czerner +Signed-off-by: Theodore Ts'o +--- + lib/ext2fs/imager.c | 41 +++++++++++++++++++++++++++++++++++++++++ + lib/ext2fs/inode.c | 2 +- + lib/ext2fs/openfs.c | 4 ++-- + lib/ext2fs/rw_bitmaps.c | 4 ++-- + misc/e2image.c | 22 +++++++++++----------- + 5 files changed, 57 insertions(+), 16 deletions(-) + +diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c +index efb85b9..7fd06f7 100644 +--- ./lib/ext2fs/imager.c ++++ b/lib/ext2fs/imager.c +@@ -195,6 +195,11 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, + char *buf, *cp; + ssize_t actual; + errcode_t retval; ++#ifdef WORDS_BIGENDIAN ++ unsigned int groups_per_block; ++ struct ext2_group_desc *gdp; ++ int j; ++#endif + + buf = malloc(fs->blocksize); + if (!buf) +@@ -204,7 +209,17 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, + * Write out the superblock + */ + memset(buf, 0, fs->blocksize); ++#ifdef WORDS_BIGENDIAN ++ /* ++ * We're writing out superblock so let's convert ++ * it to little endian and then back if needed ++ */ ++ ext2fs_swap_super(fs->super); + memcpy(buf, fs->super, SUPERBLOCK_SIZE); ++ ext2fs_swap_super(fs->super); ++#else ++ memcpy(buf, fs->super, SUPERBLOCK_SIZE); ++#endif + actual = write(fd, buf, fs->blocksize); + if (actual == -1) { + retval = errno; +@@ -218,8 +233,34 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, + /* + * Now write out the block group descriptors + */ ++ + cp = (char *) fs->group_desc; ++ ++#ifdef WORDS_BIGENDIAN ++ /* ++ * Convert group descriptors to little endian and back ++ * if needed ++ */ ++ groups_per_block = EXT2_DESC_PER_BLOCK(fs->super); ++ gdp = (struct ext2_group_desc *) cp; ++ for (j=0; j < groups_per_block*fs->desc_blocks; j++) { ++ gdp = ext2fs_group_desc(fs, fs->group_desc, j); ++ ext2fs_swap_group_desc2(fs, gdp); ++ } ++#endif ++ + actual = write(fd, cp, fs->blocksize * fs->desc_blocks); ++ ++ ++#ifdef WORDS_BIGENDIAN ++ groups_per_block = EXT2_DESC_PER_BLOCK(fs->super); ++ gdp = (struct ext2_group_desc *) cp; ++ for (j=0; j < groups_per_block*fs->desc_blocks; j++) { ++ gdp = ext2fs_group_desc(fs, fs->group_desc, j); ++ ext2fs_swap_group_desc2(fs, gdp); ++ } ++#endif ++ + if (actual == -1) { + retval = errno; + goto errout; +diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c +index ad01a9f..015cfe4 100644 +--- ./lib/ext2fs/inode.c ++++ b/lib/ext2fs/inode.c +@@ -770,7 +770,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, + } + if (fs->flags & EXT2_FLAG_IMAGE_FILE) { + inodes_per_block = fs->blocksize / EXT2_INODE_SIZE(fs->super); +- block_nr = fs->image_header->offset_inode / fs->blocksize; ++ block_nr = ext2fs_le32_to_cpu(fs->image_header->offset_inode) / fs->blocksize; + block_nr += (ino - 1) / inodes_per_block; + offset = ((ino - 1) % inodes_per_block) * + EXT2_INODE_SIZE(fs->super); +diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c +index 385d6e8..532e70f 100644 +--- ./lib/ext2fs/openfs.c ++++ b/lib/ext2fs/openfs.c +@@ -185,10 +185,10 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, + fs->image_header); + if (retval) + goto cleanup; +- if (fs->image_header->magic_number != EXT2_ET_MAGIC_E2IMAGE) ++ if (ext2fs_le32_to_cpu(fs->image_header->magic_number) != EXT2_ET_MAGIC_E2IMAGE) + return EXT2_ET_MAGIC_E2IMAGE; + superblock = 1; +- block_size = fs->image_header->fs_blocksize; ++ block_size = ext2fs_le32_to_cpu(fs->image_header->fs_blocksize); + } + + /* +diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c +index 0b532db..e86bacd 100644 +--- ./lib/ext2fs/rw_bitmaps.c ++++ b/lib/ext2fs/rw_bitmaps.c +@@ -253,7 +253,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) + ext2fs_free_mem(&buf); + + if (fs->flags & EXT2_FLAG_IMAGE_FILE) { +- blk = (fs->image_header->offset_inodemap / fs->blocksize); ++ blk = (ext2fs_le32_to_cpu(fs->image_header->offset_inodemap) / fs->blocksize); + ino_cnt = fs->super->s_inodes_count; + while (inode_bitmap && ino_cnt > 0) { + retval = io_channel_read_blk64(fs->image_io, blk++, +@@ -270,7 +270,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) + ino_itr += cnt; + ino_cnt -= cnt; + } +- blk = (fs->image_header->offset_blockmap / ++ blk = (ext2fs_le32_to_cpu(fs->image_header->offset_blockmap) / + fs->blocksize); + blk_cnt = EXT2_GROUPS_TO_CLUSTERS(fs->super, + fs->group_desc_count); +diff --git a/misc/e2image.c b/misc/e2image.c +index 5a18bb4..83ae633 100644 +--- ./misc/e2image.c ++++ b/misc/e2image.c +@@ -240,7 +240,7 @@ static void write_image_file(ext2_filsys fs, int fd) + write_header(fd, NULL, sizeof(struct ext2_image_hdr), fs->blocksize); + memset(&hdr, 0, sizeof(struct ext2_image_hdr)); + +- hdr.offset_super = seek_relative(fd, 0); ++ hdr.offset_super = ext2fs_cpu_to_le32(seek_relative(fd, 0)); + retval = ext2fs_image_super_write(fs, fd, 0); + if (retval) { + com_err(program_name, retval, "%s", +@@ -248,7 +248,7 @@ static void write_image_file(ext2_filsys fs, int fd) + exit(1); + } + +- hdr.offset_inode = seek_relative(fd, 0); ++ hdr.offset_inode = ext2fs_cpu_to_le32(seek_relative(fd, 0)); + retval = ext2fs_image_inode_write(fs, fd, + (fd != 1) ? IMAGER_FLAG_SPARSEWRITE : 0); + if (retval) { +@@ -257,7 +257,7 @@ static void write_image_file(ext2_filsys fs, int fd) + exit(1); + } + +- hdr.offset_blockmap = seek_relative(fd, 0); ++ hdr.offset_blockmap = ext2fs_cpu_to_le32(seek_relative(fd, 0)); + retval = ext2fs_image_bitmap_write(fs, fd, 0); + if (retval) { + com_err(program_name, retval, "%s", +@@ -265,7 +265,7 @@ static void write_image_file(ext2_filsys fs, int fd) + exit(1); + } + +- hdr.offset_inodemap = seek_relative(fd, 0); ++ hdr.offset_inodemap = ext2fs_cpu_to_le32(seek_relative(fd, 0)); + retval = ext2fs_image_bitmap_write(fs, fd, IMAGER_FLAG_INODEMAP); + if (retval) { + com_err(program_name, retval, "%s", +@@ -273,23 +273,23 @@ static void write_image_file(ext2_filsys fs, int fd) + exit(1); + } + +- hdr.magic_number = EXT2_ET_MAGIC_E2IMAGE; ++ hdr.magic_number = ext2fs_cpu_to_le32(EXT2_ET_MAGIC_E2IMAGE); + strcpy(hdr.magic_descriptor, "Ext2 Image 1.0"); + gethostname(hdr.fs_hostname, sizeof(hdr.fs_hostname)); + strncpy(hdr.fs_device_name, device_name, sizeof(hdr.fs_device_name)-1); + hdr.fs_device_name[sizeof(hdr.fs_device_name) - 1] = 0; +- hdr.fs_blocksize = fs->blocksize; ++ hdr.fs_blocksize = ext2fs_cpu_to_le32(fs->blocksize); + + if (stat(device_name, &st) == 0) +- hdr.fs_device = st.st_rdev; ++ hdr.fs_device = ext2fs_cpu_to_le32(st.st_rdev); + + if (fstat(fd, &st) == 0) { +- hdr.image_device = st.st_dev; +- hdr.image_inode = st.st_ino; ++ hdr.image_device = ext2fs_cpu_to_le32(st.st_dev); ++ hdr.image_inode = ext2fs_cpu_to_le32(st.st_ino); + } + memcpy(hdr.fs_uuid, fs->super->s_uuid, sizeof(hdr.fs_uuid)); + +- hdr.image_time = time(0); ++ hdr.image_time = ext2fs_cpu_to_le32(time(0)); + write_header(fd, &hdr, sizeof(struct ext2_image_hdr), fs->blocksize); + } + +@@ -1423,7 +1423,7 @@ static void install_image(char *device, char *image_fn, int type) + + ext2fs_rewrite_to_io(fs, io); + +- seek_set(fd, fs->image_header->offset_inode); ++ seek_set(fd, ext2fs_le32_to_cpu(fs->image_header->offset_inode)); + + retval = ext2fs_image_inode_read(fs, fd, 0); + if (retval) { +-- +cgit v1.1 + Property changes on: head/sysutils/e2fsprogs/files/patch-zc ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/e2fsprogs/files/patch-zd =================================================================== --- head/sysutils/e2fsprogs/files/patch-zd (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-zd (revision 469630) @@ -0,0 +1,39 @@ +From 4c41e6801fad37fedbbe8feb849eec190b41a733 Mon Sep 17 00:00:00 2001 +From: Eric Sandeen +Date: Mon, 9 Apr 2018 15:28:12 -0400 +Subject: e2fsck: warn if checkinterval and broken_system_clock both set + +If broken_system_clock is set in e2fsck.conf and this causes +the check interval to be ignored, make that clear to the user: + +e2fsck 1.44.1 (24-Mar-2018) +/dev/sda1: ignoring check interval, broken_system_clock set +/dev/sda1: clean, 11/65536 files, 12955/262144 blocks + +Signed-off-by: Eric Sandeen +Signed-off-by: Theodore Ts'o +Reviewed-by: Lukas Czerner +--- + e2fsck/unix.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/e2fsck/unix.c b/e2fsck/unix.c +index faf5af9..cbe5ec5 100644 +--- ./e2fsck/unix.c ++++ b/e2fsck/unix.c +@@ -396,7 +396,12 @@ static void check_if_skip(e2fsck_t ctx) + if (batt && ((ctx->now - fs->super->s_lastcheck) < + fs->super->s_checkinterval*2)) + reason = 0; ++ } else if (broken_system_clock && fs->super->s_checkinterval) { ++ log_out(ctx, "%s: ", ctx->device_name); ++ log_out(ctx, "%s", ++ _("ignoring check interval, broken_system_clock set\n")); + } ++ + if (reason) { + log_out(ctx, "%s", ctx->device_name); + log_out(ctx, reason, reason_arg); +-- +cgit v1.1 + Property changes on: head/sysutils/e2fsprogs/files/patch-zd ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/e2fsprogs/files/patch-ze =================================================================== --- head/sysutils/e2fsprogs/files/patch-ze (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-ze (revision 469630) @@ -0,0 +1,24 @@ +From 2bb826370c12f599fe6cc401fa83a0e7a592f0df Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Mon, 9 Apr 2018 15:37:00 -0400 +Subject: tests: don't leave temp files behind after running i_bitmaps + +Signed-off-by: Theodore Ts'o +--- + tests/i_bitmaps/script | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/i_bitmaps/script b/tests/i_bitmaps/script +index b8e3bd2..1a16d55 100644 +--- ./tests/i_bitmaps/script ++++ b/tests/i_bitmaps/script +@@ -24,5 +24,5 @@ else + rm -f $test_name.tmp + fi + +-rm -rf $TMPFILE $TMPFILE.bin $TMPFILE.1 ++rm -rf $TMPFILE $TMPFILE.bin $TMPFILE.1 $TMPFILE.2 $TMPFILE.e2i + unset IMAGE FSCK_OPT OUT EXP +-- +cgit v1.1 + Property changes on: head/sysutils/e2fsprogs/files/patch-ze ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/e2fsprogs/files/patch-zf =================================================================== --- head/sysutils/e2fsprogs/files/patch-zf (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-zf (revision 469630) @@ -0,0 +1,71 @@ +From b46fbf3d52e722d9810dad97a5fa443b280c8a82 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Sat, 7 Apr 2018 01:12:00 -0400 +Subject: tests: add new test f_ea_inode_self_ref + +Make sure we can handle a maliciously created file system containing +an inode containing an extended attribute whose e_value_inum points +back at itself. + +Signed-off-by: Theodore Ts'o +--- + tests/f_ea_inode_self_ref/expect.1 | 17 +++++++++++++++++ + tests/f_ea_inode_self_ref/expect.2 | 7 +++++++ + tests/f_ea_inode_self_ref/image.gz | Bin 0 -> 661 bytes + tests/f_ea_inode_self_ref/name | 1 + + 4 files changed, 25 insertions(+) + create mode 100644 tests/f_ea_inode_self_ref/expect.1 + create mode 100644 tests/f_ea_inode_self_ref/expect.2 + create mode 100644 tests/f_ea_inode_self_ref/image.gz + create mode 100644 tests/f_ea_inode_self_ref/name + +diff --git a/tests/f_ea_inode_self_ref/expect.1 b/tests/f_ea_inode_self_ref/expect.1 +new file mode 100644 +index 0000000..f94c04d +--- /dev/null ++++ b/tests/f_ea_inode_self_ref/expect.1 +@@ -0,0 +1,17 @@ ++Pass 1: Checking inodes, blocks, and sizes ++Inode 16 has INLINE_DATA_FL flag but extended attribute not found. Truncate? yes ++ ++Extended attribute in inode 16 has a hash (553648128) which is invalid ++Clear? yes ++ ++Pass 2: Checking directory structure ++Pass 3: Checking directory connectivity ++Pass 4: Checking reference counts ++Pass 5: Checking group summary information ++Block bitmap differences: -20 ++Fix? yes ++ ++ ++test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** ++test_filesys: 16/16 files (0.0% non-contiguous), 21/100 blocks ++Exit status is 1 +diff --git a/tests/f_ea_inode_self_ref/expect.2 b/tests/f_ea_inode_self_ref/expect.2 +new file mode 100644 +index 0000000..9398061 +--- /dev/null ++++ b/tests/f_ea_inode_self_ref/expect.2 +@@ -0,0 +1,7 @@ ++Pass 1: Checking inodes, blocks, and sizes ++Pass 2: Checking directory structure ++Pass 3: Checking directory connectivity ++Pass 4: Checking reference counts ++Pass 5: Checking group summary information ++test_filesys: 16/16 files (0.0% non-contiguous), 21/100 blocks ++Exit status is 0 +diff --git a/tests/f_ea_inode_self_ref/image.gz b/tests/f_ea_inode_self_ref/image.gz +new file mode 100644 +index 0000000..3cc733b +Binary files /dev/null and b/tests/f_ea_inode_self_ref/image.gz differ +diff --git a/tests/f_ea_inode_self_ref/name b/tests/f_ea_inode_self_ref/name +new file mode 100644 +index 0000000..4e68da8 +--- /dev/null ++++ b/tests/f_ea_inode_self_ref/name +@@ -0,0 +1 @@ ++corrupted, self-referential ea_in_inode +-- +cgit v1.1 + Property changes on: head/sysutils/e2fsprogs/files/patch-zf ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: head/sysutils/e2fsprogs/files/patch-zg =================================================================== --- head/sysutils/e2fsprogs/files/patch-zg (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-zg (revision 469630) @@ -0,0 +1,45 @@ +From d3f01729bff29e75b21994dc305e09fb055baff3 Mon Sep 17 00:00:00 2001 +From: Lukas Czerner +Date: Fri, 13 Apr 2018 14:27:49 +0200 +Subject: chattr.1: 'a' and 'i' attribute do not affect existing file + descriptors + +Change chattr man page to make it clear that 'i' and 'a' attributes +does not affect the ability to write to already existing file +descriptors + +Signed-off-by: Lukas Czerner +Signed-off-by: Theodore Ts'o +--- + misc/chattr.1.in | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/misc/chattr.1.in b/misc/chattr.1.in +index fba9cea..028ae9e 100644 +--- ./misc/chattr.1.in ++++ b/misc/chattr.1.in +@@ -121,9 +121,9 @@ although it can be displayed by + .PP + A file with the 'i' attribute cannot be modified: it cannot be deleted or + renamed, no link can be created to this file, most of the file's +-metadata can not be modified, and no data can be written +-to the file. Only the superuser or a process possessing the +-CAP_LINUX_IMMUTABLE capability can set or clear this attribute. ++metadata can not be modified, and the file can not be opened in write mode. ++Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE ++capability can set or clear this attribute. + .PP + The 'I' attribute is used by the htree code to indicate that a directory + is being indexed using hashed trees. It may not be set or reset using +@@ -191,6 +191,8 @@ maintained by Theodore Ts'o . + The 'c', 's', and 'u' attributes are not honored + by the ext2, ext3, and ext4 filesystems as implemented in the current + mainline Linux kernels. ++Setting 'a' and 'i' attributes will not affect the ability to write ++to already existing file descriptors. + .PP + The 'j' option is only useful for ext3 and ext4 file systems. + .PP +-- +cgit v1.1 + Property changes on: head/sysutils/e2fsprogs/files/patch-zg ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property