lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20201021100358.1ef28ca2@canb.auug.org.au>
Date:   Wed, 21 Oct 2020 10:03:58 +1100
From:   Stephen Rothwell <sfr@...b.auug.org.au>
To:     Theodore Ts'o <tytso@....edu>
Cc:     Eric Biggers <ebiggers@...gle.com>,
        Harshad Shirwadkar <harshadshirwadkar@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux Next Mailing List <linux-next@...r.kernel.org>
Subject: linux-next: manual merge of the ext4 tree with Linus' tree

Hi all,

Today's linux-next merge of the ext4 tree got a conflict in:

  fs/ext4/ialloc.c

between commits:

  177cc0e71008 ("ext4: factor out ext4_xattr_credits_for_new_inode()")
  02ce5316afc8 ("ext4: use fscrypt_prepare_new_inode() and fscrypt_set_context()")

from Linus' tree and commit:

  44059e503b03 ("ext4: fast commit recovery path")

from the ext4 tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/ext4/ialloc.c
index 698ca4a4db5f,2400a8200435..000000000000
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@@ -742,53 -746,122 +746,169 @@@ not_found
  	return 1;
  }
  
 +static int ext4_xattr_credits_for_new_inode(struct inode *dir, mode_t mode,
 +					    bool encrypt)
 +{
 +	struct super_block *sb = dir->i_sb;
 +	int nblocks = 0;
 +#ifdef CONFIG_EXT4_FS_POSIX_ACL
 +	struct posix_acl *p = get_acl(dir, ACL_TYPE_DEFAULT);
 +
 +	if (IS_ERR(p))
 +		return PTR_ERR(p);
 +	if (p) {
 +		int acl_size = p->a_count * sizeof(ext4_acl_entry);
 +
 +		nblocks += (S_ISDIR(mode) ? 2 : 1) *
 +			__ext4_xattr_set_credits(sb, NULL /* inode */,
 +						 NULL /* block_bh */, acl_size,
 +						 true /* is_create */);
 +		posix_acl_release(p);
 +	}
 +#endif
 +
 +#ifdef CONFIG_SECURITY
 +	{
 +		int num_security_xattrs = 1;
 +
 +#ifdef CONFIG_INTEGRITY
 +		num_security_xattrs++;
 +#endif
 +		/*
 +		 * We assume that security xattrs are never more than 1k.
 +		 * In practice they are under 128 bytes.
 +		 */
 +		nblocks += num_security_xattrs *
 +			__ext4_xattr_set_credits(sb, NULL /* inode */,
 +						 NULL /* block_bh */, 1024,
 +						 true /* is_create */);
 +	}
 +#endif
 +	if (encrypt)
 +		nblocks += __ext4_xattr_set_credits(sb,
 +						    NULL /* inode */,
 +						    NULL /* block_bh */,
 +						    FSCRYPT_SET_CONTEXT_MAX_SIZE,
 +						    true /* is_create */);
 +	return nblocks;
 +}
 +
+ int ext4_mark_inode_used(struct super_block *sb, int ino)
+ {
+ 	unsigned long max_ino = le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count);
+ 	struct buffer_head *inode_bitmap_bh = NULL, *group_desc_bh = NULL;
+ 	struct ext4_group_desc *gdp;
+ 	ext4_group_t group;
+ 	int bit;
+ 	int err = -EFSCORRUPTED;
+ 
+ 	if (ino < EXT4_FIRST_INO(sb) || ino > max_ino)
+ 		goto out;
+ 
+ 	group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
+ 	bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
+ 	inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
+ 	if (IS_ERR(inode_bitmap_bh))
+ 		return PTR_ERR(inode_bitmap_bh);
+ 
+ 	if (ext4_test_bit(bit, inode_bitmap_bh->b_data)) {
+ 		err = 0;
+ 		goto out;
+ 	}
+ 
+ 	gdp = ext4_get_group_desc(sb, group, &group_desc_bh);
+ 	if (!gdp || !group_desc_bh) {
+ 		err = -EINVAL;
+ 		goto out;
+ 	}
+ 
+ 	ext4_set_bit(bit, inode_bitmap_bh->b_data);
+ 
+ 	BUFFER_TRACE(inode_bitmap_bh, "call ext4_handle_dirty_metadata");
+ 	err = ext4_handle_dirty_metadata(NULL, NULL, inode_bitmap_bh);
+ 	if (err) {
+ 		ext4_std_error(sb, err);
+ 		goto out;
+ 	}
+ 	err = sync_dirty_buffer(inode_bitmap_bh);
+ 	if (err) {
+ 		ext4_std_error(sb, err);
+ 		goto out;
+ 	}
+ 
+ 	/* We may have to initialize the block bitmap if it isn't already */
+ 	if (ext4_has_group_desc_csum(sb) &&
+ 	    gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 		struct buffer_head *block_bitmap_bh;
+ 
+ 		block_bitmap_bh = ext4_read_block_bitmap(sb, group);
+ 		if (IS_ERR(block_bitmap_bh)) {
+ 			err = PTR_ERR(block_bitmap_bh);
+ 			goto out;
+ 		}
+ 
+ 		BUFFER_TRACE(block_bitmap_bh, "dirty block bitmap");
+ 		err = ext4_handle_dirty_metadata(NULL, NULL, block_bitmap_bh);
+ 		sync_dirty_buffer(block_bitmap_bh);
+ 
+ 		/* recheck and clear flag under lock if we still need to */
+ 		ext4_lock_group(sb, group);
+ 		if (ext4_has_group_desc_csum(sb) &&
+ 		    (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))) {
+ 			gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
+ 			ext4_free_group_clusters_set(sb, gdp,
+ 				ext4_free_clusters_after_init(sb, group, gdp));
+ 			ext4_block_bitmap_csum_set(sb, group, gdp,
+ 						   block_bitmap_bh);
+ 			ext4_group_desc_csum_set(sb, group, gdp);
+ 		}
+ 		ext4_unlock_group(sb, group);
+ 		brelse(block_bitmap_bh);
+ 
+ 		if (err) {
+ 			ext4_std_error(sb, err);
+ 			goto out;
+ 		}
+ 	}
+ 
+ 	/* Update the relevant bg descriptor fields */
+ 	if (ext4_has_group_desc_csum(sb)) {
+ 		int free;
+ 
+ 		ext4_lock_group(sb, group); /* while we modify the bg desc */
+ 		free = EXT4_INODES_PER_GROUP(sb) -
+ 			ext4_itable_unused_count(sb, gdp);
+ 		if (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
+ 			gdp->bg_flags &= cpu_to_le16(~EXT4_BG_INODE_UNINIT);
+ 			free = 0;
+ 		}
+ 
+ 		/*
+ 		 * Check the relative inode number against the last used
+ 		 * relative inode number in this group. if it is greater
+ 		 * we need to update the bg_itable_unused count
+ 		 */
+ 		if (bit >= free)
+ 			ext4_itable_unused_set(sb, gdp,
+ 					(EXT4_INODES_PER_GROUP(sb) - bit - 1));
+ 	} else {
+ 		ext4_lock_group(sb, group);
+ 	}
+ 
+ 	ext4_free_inodes_set(sb, gdp, ext4_free_inodes_count(sb, gdp) - 1);
+ 	if (ext4_has_group_desc_csum(sb)) {
+ 		ext4_inode_bitmap_csum_set(sb, group, gdp, inode_bitmap_bh,
+ 					   EXT4_INODES_PER_GROUP(sb) / 8);
+ 		ext4_group_desc_csum_set(sb, group, gdp);
+ 	}
+ 
+ 	ext4_unlock_group(sb, group);
+ 	err = ext4_handle_dirty_metadata(NULL, NULL, group_desc_bh);
+ 	sync_dirty_buffer(group_desc_bh);
+ out:
+ 	return err;
+ }
+ 
  /*
   * There are two policies for allocating an inode.  If the new inode is
   * a directory, then a forward search is made for a block group with both
@@@ -818,8 -891,8 +938,8 @@@ struct inode *__ext4_new_inode(handle_
  	struct inode *ret;
  	ext4_group_t i;
  	ext4_group_t flex_group;
- 	struct ext4_group_info *grp;
+ 	struct ext4_group_info *grp = NULL;
 -	int encrypt = 0;
 +	bool encrypt = false;
  
  	/* Cannot create files in a deleted directory */
  	if (!dir || !dir->i_nlink)

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ