Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 May 2018 11:56:29 +0000 (UTC)
From:      Matthias Andree <mandree@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r469630 - in head/sysutils/e2fsprogs: . files
Message-ID:  <201805111156.w4BBuTIp083753@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mandree
Date: Fri May 11 11:56:29 2018
New Revision: 469630
URL: https://svnweb.freebsd.org/changeset/ports/469630

Log:
  Cherry-pick upstream bug fixes from Git.
  
  This is pending an 1.44.2 release, and contains these fixes from maint:
  filefrag: avoid temporary buffer overflow
  libext2fs: add sanity checks for ea_in_inode
  e2image: fix metadata image handling on big endian systems
  e2fsck: warn if checkinterval and broken_system_clock both set
  tests: don't leave temp files behind after running i_bitmaps
  tests: add new test f_ea_inode_self_ref
  chattr.1: 'a' and 'i' attribute do not affect existing file
  
  MFH:		2018Q2

Added:
  head/sysutils/e2fsprogs/files/patch-za   (contents, props changed)
  head/sysutils/e2fsprogs/files/patch-zb   (contents, props changed)
  head/sysutils/e2fsprogs/files/patch-zc   (contents, props changed)
  head/sysutils/e2fsprogs/files/patch-zd   (contents, props changed)
  head/sysutils/e2fsprogs/files/patch-ze   (contents, props changed)
  head/sysutils/e2fsprogs/files/patch-zf   (contents, props changed)
  head/sysutils/e2fsprogs/files/patch-zg   (contents, props changed)
Modified:
  head/sysutils/e2fsprogs/Makefile

Modified: head/sysutils/e2fsprogs/Makefile
==============================================================================
--- head/sysutils/e2fsprogs/Makefile	Fri May 11 11:50:16 2018	(r469629)
+++ head/sysutils/e2fsprogs/Makefile	Fri May 11 11:56:29 2018	(r469630)
@@ -3,7 +3,7 @@
 
 PORTNAME=	e2fsprogs
 PORTVERSION=	1.44.1
-PORTREVISION?=	0
+PORTREVISION?=	1
 CATEGORIES?=	sysutils
 MASTER_SITES=	KERNEL_ORG/linux/kernel/people/tytso/${PORTNAME}/v${PORTVERSION}
 

Added: head/sysutils/e2fsprogs/files/patch-za
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-za	Fri May 11 11:56:29 2018	(r469630)
@@ -0,0 +1,34 @@
+From 17a1f2c1929630e3a79e6b98168d56f96acf2e8b Mon Sep 17 00:00:00 2001
+From: Andreas Dilger <adilger@dilger.ca>
+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 <wei3.liu@intel.com>
+Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10335
+Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ 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
+

Added: head/sysutils/e2fsprogs/files/patch-zb
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-zb	Fri May 11 11:56:29 2018	(r469630)
@@ -0,0 +1,73 @@
+From 9db53e3fec3413572a2240bd374e76353fab9cbe Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+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 <wen.xu@gatech.edu>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ 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
+

Added: head/sysutils/e2fsprogs/files/patch-zc
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-zc	Fri May 11 11:56:29 2018	(r469630)
@@ -0,0 +1,226 @@
+From bfc1856029ff6851845de27114fea899bbdbccbe Mon Sep 17 00:00:00 2001
+From: Lukas Czerner <lczerner@redhat.com>
+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 <lczerner@redhat.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ 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
+

Added: head/sysutils/e2fsprogs/files/patch-zd
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-zd	Fri May 11 11:56:29 2018	(r469630)
@@ -0,0 +1,39 @@
+From 4c41e6801fad37fedbbe8feb849eec190b41a733 Mon Sep 17 00:00:00 2001
+From: Eric Sandeen <sandeen@redhat.com>
+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 <sandeen@redhat.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Reviewed-by: Lukas Czerner <lczerner@redhat.com>
+---
+ 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
+

Added: head/sysutils/e2fsprogs/files/patch-ze
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-ze	Fri May 11 11:56:29 2018	(r469630)
@@ -0,0 +1,24 @@
+From 2bb826370c12f599fe6cc401fa83a0e7a592f0df Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+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 <tytso@mit.edu>
+---
+ 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
+

Added: head/sysutils/e2fsprogs/files/patch-zf
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-zf	Fri May 11 11:56:29 2018	(r469630)
@@ -0,0 +1,71 @@
+From b46fbf3d52e722d9810dad97a5fa443b280c8a82 Mon Sep 17 00:00:00 2001
+From: Theodore Ts'o <tytso@mit.edu>
+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 <tytso@mit.edu>
+---
+ 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
+

Added: head/sysutils/e2fsprogs/files/patch-zg
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-zg	Fri May 11 11:56:29 2018	(r469630)
@@ -0,0 +1,45 @@
+From d3f01729bff29e75b21994dc305e09fb055baff3 Mon Sep 17 00:00:00 2001
+From: Lukas Czerner <lczerner@redhat.com>
+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 <lczerner@redhat.com>
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+---
+ 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 <tytso@alum.mit.edu>.
+ 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
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805111156.w4BBuTIp083753>