Index: head/sysutils/e2fsprogs/Makefile =================================================================== --- head/sysutils/e2fsprogs/Makefile (revision 370471) +++ head/sysutils/e2fsprogs/Makefile (revision 370472) @@ -1,152 +1,141 @@ # Created by: Maxim Sobolev # $FreeBSD$ PORTNAME= e2fsprogs PORTVERSION= 1.42.12 -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 PORTSCOUT= ignore # cannot handle the version in the directory -PATCH_STRIP= -p1 USES= gmake pkgconfig tar:xz USE_CSTD= gnu99 USE_LDCONFIG= yes GNU_CONFIGURE= yes CONFIGURE_ARGS+=--disable-fsck --disable-e2initrd-helper \ --enable-quota \ --with-root-prefix='${PREFIX}' CPPFLAGS+= -I${WRKSRC}/lib -I${LOCALBASE}/include # -D_EXT2_USE_C_VERSIONS MAKE_ARGS+= LDFLAGS='${LDFLAGS} -L${LOCALBASE}/lib' pkgconfigdir='${PREFIX}/libdata/pkgconfig' MAKE_ENV+= CHECK_CMD=@true .if !defined(MASTERDIR) OPTIONS_DEFINE= DOCS NLS OPTIONS_DEFAULT= NLS OPTIONS_EXCLUDE+= EXAMPLES PORTDOCS= COPYING RELEASE-NOTES post-extract: @${CHMOD} u+w ${WRKSRC}/po/*.po ${WRKSRC}/po/*.pot \ ${WRKSRC}/${CONFIGURE_SCRIPT} .endif PKGDEINSTALL= ${PKGINSTALL} # get more details into tinderbox logs .if defined(PACKAGE_BUILDING) MAKE_ARGS+= V=1 .endif .include .if ${PORT_OPTIONS:MNLS} USES+= gettext iconv:build .endif .include .if ${PORT_OPTIONS:MNLS} PLIST_SUB= NLS="" . 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 PLIST_SUB= NLS="@comment " libintl= .endif 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/" ${WRKSRC}/tests/[a-t]_*/script @${REINPLACE_CMD} -e 's///' ${WRKSRC}/*/*.c # disable f_mmp_garbage, fails on FreeBSD, and the resize*big_expand tests, # which are too unwieldy to run automatically (need too much free space). # f_extent_oobounds fails in Tinderbox and is fine outside, reason unclear. .for i in f_mmp_garbage m_bigjournal r_64bit_big_expand r_bigalloc_big_expand r_ext4_big_expand @${MV} ${WRKSRC}/tests/${i} ${WRKSRC}/tests/disabled_test-${i} .endfor .if ${MASTERDIR} == ${.CURDIR} -# Regression that apparently causes use-after-free in -# http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/commit/?h=maint&id=47fee2ef6a23ae06f680336ffde57caa64604a4c -# and can be reproduced under MALLOC_OPTIONS=J regime on 9.3-amd64, or -# alternatively confirmed with valgrind, was reported upstream. -# -# Let's wait until 2014-10-15 whether upstream provides a fix, -# else we'll bump PORTEPOCH and roll back to 1.42.10; -# 1.42.11 is also faulty. -BROKEN= Use-after-free bug, see ${.CURDIR}/Makefile comments for details - pre-build: # fix up Makefile ordering for parallel builds cd ${WRKSRC}/lib/et && ${DO_MAKE_BUILD} compile_et cd ${WRKSRC}/e2fsck && ${DO_MAKE_BUILD} prof_err.h 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 \ STATIC_LIBS="../lib/libext2fs.a ../lib/libcom_err.a \ ../lib/libblkid.a ../lib/libuuid.a" \ LIBINTL=${libintl} # 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 beyond libc and libgcc: " @a="$$(ldd ${WRKSRC}/e2fsck/e2fsck 2>/dev/null \ | ${GREP} -v 'not a dynamic executable' \ | ${GREP} '=>' \ | ${AWK} '{print $$3;}' \ | ${EGREP} -v '^/lib/libgcc(_s)?\.so\.' \ | ${GREP} -v '^/lib/libc\.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 @${ECHO_CMD} '===> Running e2fsprogs self-test suite' # do not add -j options to ${MAKE_CMD} below, this might break # due to excessive disk space use. cd ${WRKSRC}/tests && ${MKDIR} ${WRKDIR}/tmp && ${MAKE_CMD} check TMPDIR=${WRKDIR}/tmp \ || { head -n30000 ${WRKSRC}/tests/*.failed 2>/dev/null ; exit 1 ; } post-install: ${RM} -f ${STAGEDIR}${PREFIX}/sbin/uuidd ${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 # the next line closes .if ${MASTERDIR} == ${.CURDIR} .endif .include Index: head/sysutils/e2fsprogs/files/patch-e2fsck__unix.c =================================================================== --- head/sysutils/e2fsprogs/files/patch-e2fsck__unix.c (revision 370471) +++ head/sysutils/e2fsprogs/files/patch-e2fsck__unix.c (revision 370472) @@ -1,72 +1,72 @@ ---- ./e2fsck/unix.c.orig 2013-12-29 05:18:02.000000000 +0100 -+++ ./e2fsck/unix.c 2014-01-06 23:26:48.000000000 +0100 +--- e2fsck/unix.c.orig 2014-08-12 18:19:37 UTC ++++ e2fsck/unix.c @@ -9,8 +9,6 @@ * %End-Header% */ -#define _XOPEN_SOURCE 600 /* for inclusion of sa_handler in Solaris */ - #include "config.h" #include #ifdef HAVE_STDLIB_H @@ -37,7 +35,7 @@ #include #endif #ifdef HAVE_MALLOC_H -#include +#include #endif #ifdef HAVE_SYS_TYPES_H #include -@@ -584,6 +582,24 @@ +@@ -590,6 +588,24 @@ return 0; } +static int e2fsck_progress_once(e2fsck_t ctx, int pass, unsigned long cur, unsigned long max) +{ + char buf[80]; + float percent; + + if (pass == 0) + return 0; + + percent = calc_percent(&e2fsck_tbl, pass, cur, max); + e2fsck_simple_progress(ctx, ctx->device_name, + percent, 0); + + printf("\n"); + ctx->progress = 0; + return 0; +} + + #define PATH_SET "PATH=/sbin" /* -@@ -616,6 +632,17 @@ +@@ -622,6 +638,17 @@ ctx->progress = e2fsck_update_progress; } +static void signal_progress_now(int sig EXT2FS_ATTR((unused))) +{ + e2fsck_t ctx = e2fsck_global_ctx; + + if (!ctx) + return; + + ctx->progress = e2fsck_progress_once; + ctx->progress_fd = 0; +} + static void signal_progress_off(int sig EXT2FS_ATTR((unused))) { e2fsck_t ctx = e2fsck_global_ctx; -@@ -995,6 +1022,8 @@ +@@ -1001,6 +1028,8 @@ sigaction(SIGUSR1, &sa, 0); sa.sa_handler = signal_progress_off; sigaction(SIGUSR2, &sa, 0); + sa.sa_handler = signal_progress_now; + sigaction(SIGINFO, &sa, 0); #endif /* Update our PATH to include /sbin if we need to run badblocks */ Index: head/sysutils/e2fsprogs/files/patch-lib__ext2fs__ext2_fs.h =================================================================== --- head/sysutils/e2fsprogs/files/patch-lib__ext2fs__ext2_fs.h (revision 370471) +++ head/sysutils/e2fsprogs/files/patch-lib__ext2fs__ext2_fs.h (revision 370472) @@ -1,11 +1,11 @@ ---- ./lib/ext2fs/ext2_fs.h.orig 2013-12-29 05:18:02.000000000 +0100 -+++ ./lib/ext2fs/ext2_fs.h 2014-01-06 23:26:48.000000000 +0100 -@@ -456,7 +456,7 @@ +--- lib/ext2fs/ext2_fs.h.orig 2014-08-02 20:26:22 UTC ++++ lib/ext2fs/ext2_fs.h +@@ -461,7 +461,7 @@ #define i_dir_acl i_size_high -#if defined(__KERNEL__) || defined(__linux__) +#if defined(__KERNEL__) || defined(__linux__) || defined(__FreeBSD__) #define i_reserved1 osd1.linux1.l_i_reserved1 #define i_frag osd2.linux2.l_i_frag #define i_fsize osd2.linux2.l_i_fsize Index: head/sysutils/e2fsprogs/files/patch-lib__ext2fs__tdb.c =================================================================== --- head/sysutils/e2fsprogs/files/patch-lib__ext2fs__tdb.c (revision 370471) +++ head/sysutils/e2fsprogs/files/patch-lib__ext2fs__tdb.c (revision 370472) @@ -1,10 +1,10 @@ ---- ./lib/ext2fs/tdb.c.orig 2012-07-06 15:37:27.000000000 +0200 -+++ ./lib/ext2fs/tdb.c 2014-01-06 23:26:48.000000000 +0100 +--- lib/ext2fs/tdb.c.orig 2014-06-25 19:19:40 UTC ++++ lib/ext2fs/tdb.c @@ -36,7 +36,6 @@ #define HAVE_UTIME_H #define HAVE_UTIME #endif -#define _XOPEN_SOURCE 600 #include "config.h" #include Index: head/sysutils/e2fsprogs/files/patch-lib__ext2fs__tst_bitops.c =================================================================== --- head/sysutils/e2fsprogs/files/patch-lib__ext2fs__tst_bitops.c (revision 370471) +++ head/sysutils/e2fsprogs/files/patch-lib__ext2fs__tst_bitops.c (revision 370472) @@ -1,11 +1,11 @@ ---- ./lib/ext2fs/tst_bitops.c.orig 2012-07-06 15:37:27.000000000 +0200 -+++ ./lib/ext2fs/tst_bitops.c 2014-01-06 23:26:48.000000000 +0100 +--- lib/ext2fs/tst_bitops.c.orig 2014-06-25 19:19:15 UTC ++++ lib/ext2fs/tst_bitops.c @@ -104,7 +104,7 @@ bigarray = malloc(1 << 29); if (!bigarray) { fprintf(stderr, "Failed to allocate scratch memory!\n"); - exit(1); + exit(0); } bigarray[BIG_TEST_BIT >> 3] = 0; Index: head/sysutils/e2fsprogs/files/patch-lib__uuid__gen_uuid.c =================================================================== --- head/sysutils/e2fsprogs/files/patch-lib__uuid__gen_uuid.c (revision 370471) +++ head/sysutils/e2fsprogs/files/patch-lib__uuid__gen_uuid.c (revision 370472) @@ -1,39 +1,39 @@ ---- ./lib/uuid/gen_uuid.c.orig 2013-12-16 07:32:00.000000000 +0100 -+++ ./lib/uuid/gen_uuid.c 2014-01-06 23:26:48.000000000 +0100 +--- lib/uuid/gen_uuid.c.orig 2014-07-03 14:33:48 UTC ++++ lib/uuid/gen_uuid.c @@ -91,6 +91,7 @@ #ifdef HAVE_SYS_RESOURCE_H #include #endif +#include #include "uuidP.h" #include "uuidd.h" @@ -300,6 +301,28 @@ } } close(sd); +#else + struct ifaddrs *ifaddrsp, *ifaddrp; + unsigned char *a; + + if (getifaddrs(&ifaddrsp) < 0) + return -1; + for (ifaddrp = ifaddrsp; ifaddrp != NULL; ifaddrp = ifaddrp->ifa_next) + { + if (ifaddrp->ifa_addr == NULL) + continue; + if (ifaddrp->ifa_addr->sa_family != AF_LINK) + continue; + a = LLADDR((struct sockaddr_dl *)ifaddrp->ifa_addr); + if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5]) + continue; + if (node_id) { + memcpy(node_id, a, 6); + freeifaddrs(ifaddrsp); + return 1; + } + } + freeifaddrs(ifaddrsp); #endif return 0; } Index: head/sysutils/e2fsprogs/files/patch-misc__Makefile.in =================================================================== --- head/sysutils/e2fsprogs/files/patch-misc__Makefile.in (revision 370471) +++ head/sysutils/e2fsprogs/files/patch-misc__Makefile.in (revision 370472) @@ -1,79 +1,79 @@ ---- ./misc/Makefile.in.orig 2013-12-26 06:26:22.000000000 +0100 -+++ ./misc/Makefile.in 2014-01-06 23:26:48.000000000 +0100 +--- misc/Makefile.in.orig 2014-08-02 23:41:18 UTC ++++ misc/Makefile.in @@ -28,15 +28,15 @@ SPROGS= mke2fs badblocks tune2fs dumpe2fs $(BLKID_PROG) logsave \ $(E2IMAGE_PROG) @FSCK_PROG@ e2undo -USPROGS= mklost+found filefrag e2freefrag $(UUIDD_PROG) $(E4DEFRAG_PROG) +USPROGS= mklost+found e2freefrag $(UUIDD_PROG) $(E4DEFRAG_PROG) SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ e2label.8 $(FINDFS_MAN) $(BLKID_MAN) $(E2IMAGE_MAN) \ - logsave.8 filefrag.8 e2freefrag.8 e2undo.8 \ - $(UUIDD_MAN) $(E4DEFRAG_MAN) @FSCK_MAN@ + logsave.8 e2freefrag.8 e2undo.8 \ + $(E4DEFRAG_MAN) @FSCK_MAN@ FMANPAGES= mke2fs.conf.5 ext4.5 -UPROGS= chattr lsattr @UUID_CMT@ uuidgen -UMANPAGES= chattr.1 lsattr.1 @UUID_CMT@ uuidgen.1 +UPROGS= chattr lsattr +UMANPAGES= chattr.1 lsattr.1 LPROGS= @E2INITRD_PROG@ -@@ -125,14 +125,14 @@ +@@ -127,14 +127,14 @@ mke2fs.conf: $(srcdir)/mke2fs.conf.in if test -f $(srcdir)/mke2fs.conf.custom.in ; then \ - cp $(srcdir)/mke2fs.conf.custom.in mke2fs.conf; \ + cp $(srcdir)/mke2fs.conf.custom.in mke2fs.conf.dist; \ else \ - cp $(srcdir)/mke2fs.conf.in mke2fs.conf; \ + cp $(srcdir)/mke2fs.conf.in mke2fs.conf.dist; \ fi default_profile.c: mke2fs.conf $(srcdir)/profile-to-c.awk $(E) " PROFILE_TO_C mke2fs.conf" - $(Q) $(AWK) -f $(srcdir)/profile-to-c.awk < mke2fs.conf \ + $(Q) $(AWK) -f $(srcdir)/profile-to-c.awk < mke2fs.conf.dist \ > default_profile.c profile.o: $(E) " CC $<" -@@ -498,34 +498,9 @@ +@@ -515,34 +515,9 @@ (cd $(DESTDIR)$(man5dir); \ $(LN) $(LINK_INSTALL_FLAGS) ext4.5 $$i.5); \ done - $(Q) if test -f $(DESTDIR)$(root_sysconfdir)/mke2fs.conf; then \ - if cmp -s $(DESTDIR)$(root_sysconfdir)/mke2fs.conf \ - mke2fs.conf; then \ - true; \ - else \ - if grep -q ext4dev $(DESTDIR)$(root_sysconfdir)/mke2fs.conf ; then \ - $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf.e2fsprogs-new"; \ - $(INSTALL_DATA) mke2fs.conf \ - $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-new; \ - echo "Warning: installing mke2fs.conf in $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-new"; \ - echo "Check to see if you need to update your $(root_sysconfdir)/mke2fs.conf"; \ - else \ - $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf"; \ - mv $(DESTDIR)$(root_sysconfdir)/mke2fs.conf \ - $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-old; \ - $(INSTALL_DATA) mke2fs.conf \ - $(DESTDIR)$(root_sysconfdir)/mke2fs.conf; \ - echo "Your mke2fs.conf is too old. Backing up old version in"; \ - echo "$(DESTDIR)$(root_sysconfdir)/mke2fs.conf.e2fsprogs-old. Please check to see"; \ - echo "if you have any local customizations that you wish to preserve."; \ - fi; \ - echo " "; \ - fi; \ - else \ - $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf"; \ - $(INSTALL_DATA) mke2fs.conf \ - $(DESTDIR)$(root_sysconfdir)/mke2fs.conf; \ - fi + $(Q) $(ES) " INSTALL_DATA $(root_sysconfdir)/mke2fs.conf"; \ + $(INSTALL_DATA) mke2fs.conf.dist \ + $(DESTDIR)$(root_sysconfdir)/mke2fs.conf.dist install-strip: install $(Q) for i in $(SPROGS); do \ Index: head/sysutils/e2fsprogs/files/patch-misc__tune2fs.c =================================================================== --- head/sysutils/e2fsprogs/files/patch-misc__tune2fs.c (revision 370471) +++ head/sysutils/e2fsprogs/files/patch-misc__tune2fs.c (revision 370472) @@ -1,20 +1,20 @@ ---- ./misc/tune2fs.c.orig 2013-12-29 05:18:02.000000000 +0100 -+++ ./misc/tune2fs.c 2014-01-06 23:43:47.000000000 +0100 +--- misc/tune2fs.c.orig 2014-08-02 20:26:22 UTC ++++ misc/tune2fs.c @@ -25,7 +25,6 @@ * 94/03/06 - Added the checks interval from Uwe Ohse (uwe@tirka.gun.de) */ -#define _XOPEN_SOURCE 600 /* for inclusion of strptime() */ #include "config.h" #include #include @@ -52,6 +51,9 @@ #include #include +#include +#include + #include "ext2fs/ext2_fs.h" #include "ext2fs/ext2fs.h" #include "et/com_err.h" Index: head/sysutils/e2fsprogs/files/patch-zzz-f38676c3e4001359b96576204e9024557ef5fd1b =================================================================== --- head/sysutils/e2fsprogs/files/patch-zzz-f38676c3e4001359b96576204e9024557ef5fd1b (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-zzz-f38676c3e4001359b96576204e9024557ef5fd1b (revision 370472) @@ -0,0 +1,64 @@ +commit f38676c3e4001359b96576204e9024557ef5fd1b +Author: Theodore Ts'o +Date: Wed Oct 8 11:47:00 2014 -0400 + + e2fsprogs: 1.42.11 regression in memory handling: use-after-free since commit 47fee2e "e2fsprogs: introduce ext2fs_close_free() helper" + + Hi Matthias, + + Thanks for reporting this. I'm not 100% sure this will fix your + problem, since your specific valgrind failures aren't reproducing for + me. That being said, I was able to find a valgrind failure, and after + looking closely at the commit that you bisected things to, I found a + bug which was introduced by commit 47fee2ef6a23a. + + Could you check and see if this fixes the problems you are seeing? + + Many thanks!! + + - Ted + + commit ebdf895b43a1ce499e4d2556a201e2a753fc422f + Author: Theodore Ts'o + Date: Wed Oct 8 11:18:41 2014 -0400 + + e2fsck: fix free pointer dereferences + + Commit 47fee2ef6a23a introduces some free pointer dereference bugs by + not clearing ctx->fs after calling ext2fs_close_free(). + + Reported-by: Matthias Andree + Cc: Lukas Czerner + Signed-off-by: Theodore Ts'o + +diff --git a/e2fsck/unix.c b/e2fsck/unix.c +index 66debcd..10036e7 100644 +--- ./e2fsck/unix.c ++++ ./e2fsck/unix.c +@@ -458,7 +458,7 @@ static void check_if_skip(e2fsck_t ctx) + } + log_out(ctx, "\n"); + skip: +- ext2fs_close_free(&fs); ++ ext2fs_close_free(&ctx->fs); + e2fsck_free_context(ctx); + exit(FSCK_OK); + } +@@ -1462,7 +1462,7 @@ failure: + /* + * Restart in order to reopen fs but this time start mmp. + */ +- ext2fs_close_free(&fs); ++ ext2fs_close_free(&ctx->fs); + flags &= ~EXT2_FLAG_SKIP_MMP; + goto restart; + } +@@ -1692,7 +1692,7 @@ no_journal: + _("while resetting context")); + fatal_error(ctx, 0); + } +- ext2fs_close_free(&fs); ++ ext2fs_close_free(&ctx->fs); + goto restart; + } + if (run_result & E2F_FLAG_ABORT) Property changes on: head/sysutils/e2fsprogs/files/patch-zzz-f38676c3e4001359b96576204e9024557ef5fd1b ___________________________________________________________________ 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-zzz-f8d3d1661885a07ac9ef639dda0ce23d181a2c73 =================================================================== --- head/sysutils/e2fsprogs/files/patch-zzz-f8d3d1661885a07ac9ef639dda0ce23d181a2c73 (nonexistent) +++ head/sysutils/e2fsprogs/files/patch-zzz-f8d3d1661885a07ac9ef639dda0ce23d181a2c73 (revision 370472) @@ -0,0 +1,90 @@ +commit f8d3d1661885a07ac9ef639dda0ce23d181a2c73 +Author: Theodore Ts'o +Date: Wed Oct 8 12:18:32 2014 -0400 + + resize2fs: fix fs->blocksize dereference after fs has been freed] + + FYI, you'll probably want this patch too, since it's applicable to 1.42.12. + + - Ted + + Commit 77255cf36944b introduced a use after free bug. + + Signed-off-by: Theodore Ts'o + +diff --git a/resize/main.c b/resize/main.c +index c107028..983d8c2 100644 +--- ./resize/main.c ++++ ./resize/main.c +@@ -181,6 +181,7 @@ int main (int argc, char ** argv) + ext2fs_struct_stat st_buf; + __s64 new_file_size; + unsigned int sys_page_size = 4096; ++ unsigned int blocksize; + long sysval; + int len, mount_flags; + char *mtpt; +@@ -366,7 +367,8 @@ int main (int argc, char ** argv) + * defaults and for making sure the new filesystem doesn't + * exceed the partition size. + */ +- retval = ext2fs_get_device_size2(device_name, fs->blocksize, ++ blocksize = fs->blocksize; ++ retval = ext2fs_get_device_size2(device_name, blocksize, + &max_size); + if (retval) { + com_err(program_name, retval, "%s", +@@ -386,8 +388,8 @@ int main (int argc, char ** argv) + } else { + new_size = max_size; + /* Round down to an even multiple of a pagesize */ +- if (sys_page_size > fs->blocksize) +- new_size &= ~((sys_page_size / fs->blocksize)-1); ++ if (sys_page_size > blocksize) ++ new_size &= ~((sys_page_size / blocksize)-1); + } + if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super, + EXT4_FEATURE_INCOMPAT_64BIT)) { +@@ -423,7 +425,7 @@ int main (int argc, char ** argv) + * automatically extend it in a sparse fashion by writing the + * last requested block. + */ +- new_file_size = ((__u64) new_size) * fs->blocksize; ++ new_file_size = ((__u64) new_size) * blocksize; + if ((__u64) new_file_size > + (((__u64) 1) << (sizeof(st_buf.st_size)*8 - 1)) - 1) + fd = -1; +@@ -437,13 +439,13 @@ int main (int argc, char ** argv) + fprintf(stderr, _("The containing partition (or device)" + " is only %llu (%dk) blocks.\nYou requested a new size" + " of %llu blocks.\n\n"), max_size, +- fs->blocksize / 1024, new_size); ++ blocksize / 1024, new_size); + exit(1); + } + if (new_size == ext2fs_blocks_count(fs->super)) { + fprintf(stderr, _("The filesystem is already %llu (%dk) " + "blocks long. Nothing to do!\n\n"), new_size, +- fs->blocksize / 1024); ++ blocksize / 1024); + exit(0); + } + if (mount_flags & EXT2_MF_MOUNTED) { +@@ -453,7 +455,7 @@ int main (int argc, char ** argv) + bigalloc_check(fs, force); + printf(_("Resizing the filesystem on " + "%s to %llu (%dk) blocks.\n"), +- device_name, new_size, fs->blocksize / 1024); ++ device_name, new_size, blocksize / 1024); + retval = resize_fs(fs, &new_size, flags, + ((flags & RESIZE_PERCENT_COMPLETE) ? + resize_progress_func : 0)); +@@ -470,7 +472,7 @@ int main (int argc, char ** argv) + exit(1); + } + printf(_("The filesystem on %s is now %llu (%dk) blocks long.\n\n"), +- device_name, new_size, fs->blocksize / 1024); ++ device_name, new_size, blocksize / 1024); + + if ((st_buf.st_size > new_file_size) && + (fd > 0)) { Property changes on: head/sysutils/e2fsprogs/files/patch-zzz-f8d3d1661885a07ac9ef639dda0ce23d181a2c73 ___________________________________________________________________ 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