Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1653970

[PATCH 05/28] ext4: attach jinode after creation of xattr inode

From Tahsin Erdogan <tahsin@google.com>
Newsgroups linux.kernel
Subject [PATCH 05/28] ext4: attach jinode after creation of xattr inode
Date 2017-05-31 10:20 +0200
Message-ID <tN71g-2f2-37@gated-at.bofh.it> (permalink)
References <tN71f-2f2-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


In data=ordered mode jinode needs to be attached to the xattr inode when
writing data to it. Attachment normally occurs during file open for regular
files. Since we are not using file interface to write to the xattr inode,
the jinode attach needs to be done manually.

Otherwise the following crash occurs in data=ordered mode.

 BUG: unable to handle kernel NULL pointer dereference at           (null)
 IP: jbd2_journal_file_inode+0x37/0x110
 PGD 13b3c0067
 P4D 13b3c0067
 PUD 137660067
 PMD 0

 Oops: 0000 [#1] SMP
 CPU: 3 PID: 1877 Comm: python Not tainted 4.12.0-rc1+ #749
 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
 task: ffff88010e368980 task.stack: ffffc90000374000
 RIP: 0010:jbd2_journal_file_inode+0x37/0x110
 RSP: 0018:ffffc90000377980 EFLAGS: 00010246
 RAX: 0000000000000000 RBX: ffff880123b06230 RCX: 0000000000280000
 RDX: 0000000000000006 RSI: 0000000000000000 RDI: ffff88012c8585d0
 RBP: ffffc900003779b0 R08: 0000000000000202 R09: 0000000000000001
 R10: 0000000000000000 R11: 0000000000000400 R12: ffff8801111f81c0
 R13: ffff88013b2b6800 R14: ffffc90000377ab0 R15: 0000000000000001
 FS:  00007f0c99b77740(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000000000000000 CR3: 0000000136d91000 CR4: 00000000000006e0
 Call Trace:
  jbd2_journal_inode_add_write+0xe/0x10
  ext4_map_blocks+0x59e/0x620
  ext4_xattr_set_entry+0x501/0x7d0
  ext4_xattr_block_set+0x1b2/0x9b0
  ext4_xattr_set_handle+0x322/0x4f0
  ext4_xattr_set+0x144/0x1a0
  ext4_xattr_user_set+0x34/0x40
  __vfs_setxattr+0x66/0x80
  __vfs_setxattr_noperm+0x69/0x1c0
  vfs_setxattr+0xa2/0xb0
  setxattr+0x12e/0x150
  path_setxattr+0x87/0xb0
  SyS_setxattr+0xf/0x20
  entry_SYSCALL_64_fastpath+0x18/0xad

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
---
 fs/ext4/xattr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 12210fe87ea3..8e123533315f 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -826,6 +826,7 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
 					     struct inode *inode)
 {
 	struct inode *ea_inode = NULL;
+	int err;
 
 	/*
 	 * Let the next inode be the goal, so we try and allocate the EA inode
@@ -848,6 +849,11 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
 		 */
 		EXT4_XATTR_INODE_SET_PARENT(ea_inode, inode->i_ino);
 		unlock_new_inode(ea_inode);
+		err = ext4_inode_attach_jinode(ea_inode);
+		if (err) {
+			iput(ea_inode);
+			return ERR_PTR(err);
+		}
 	}
 
 	return ea_inode;
-- 
2.13.0.219.gdb65acc882-goog

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 01/28] ext4: xattr-in-inode support Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:20 +0200
  [PATCH 05/28] ext4: attach jinode after creation of xattr inode Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:20 +0200
  [PATCH 08/28] ext4: fix ref counting for ea_inode Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:20 +0200
  [PATCH 25/28] ext4: add ext4_is_quota_file() Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 15/28] ext4: fix ext4_xattr_move_to_block() Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 24/28] ext4: rename mb block cache functions Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 21/28] ext4: modify ext4_xattr_ino_array to hold struct inode * Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 23/28] mbcache: make mbcache more generic Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 13/28] ext4: ext4_xattr_value_same() should return false for external data Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 11/28] ext4: clean up ext4_xattr_inode_get() Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 12/28] ext4: add missing le32_to_cpu(e_value_inum) conversions Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 20/28] ext4: improve journal credit handling in set xattr paths Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 19/28] ext4: ext4_xattr_delete_inode() should return accurate errors Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 14/28] ext4: fix ext4_xattr_make_inode_space() value size calculation Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 16/28] ext4: fix ext4_xattr_cmp() Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:30 +0200
  [PATCH 10/28] ext4: change ext4_xattr_inode_iget() signature Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:40 +0200
  [PATCH 04/28] ext4: do not set posix acls on xattr inodes Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:40 +0200
  [PATCH 07/28] ext4: call journal revoke when freeing ea_inode blocks Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:40 +0200
    Re: [PATCH 07/28] ext4: call journal revoke when freeing ea_inode  blocks "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-05-31 18:20 +0200
      Re: [PATCH 07/28] ext4: call journal revoke when freeing ea_inode blocks Tahsin Erdogan <tahsin@google.com> - 2017-05-31 23:10 +0200
      Re: [PATCH 07/28] ext4: call journal revoke when freeing ea_inode  blocks Andreas Dilger <adilger@dilger.ca> - 2017-06-06 00:10 +0200
  [PATCH 09/28] ext4: extended attribute value size limit is enforced by vfs Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:40 +0200
    Re: [PATCH 09/28] ext4: extended attribute value size limit is  enforced by vfs "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-05-31 18:10 +0200
      Re: [PATCH 09/28] ext4: extended attribute value size limit is  enforced by vfs Tahsin Erdogan <tahsin@google.com> - 2017-05-31 18:20 +0200
  [PATCH 06/28] ext4: ea_inode owner should be the same as the inode owner Tahsin Erdogan <tahsin@google.com> - 2017-05-31 10:40 +0200
  Re: [PATCH 01/28] ext4: xattr-in-inode support "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-05-31 18:50 +0200
    Re: [PATCH 01/28] ext4: xattr-in-inode support Tahsin Erdogan <tahsin@google.com> - 2017-05-31 22:10 +0200
      [PATCH v2 01/28] ext4: xattr-in-inode support Tahsin Erdogan <tahsin@google.com> - 2017-06-01 18:00 +0200

csiph-web