1 ext4: attach jinode after creation of xattr inode
3 From: Tahsin Erdogan <tahsin@google.com>
5 In data=ordered mode jinode needs to be attached to the xattr inode when
6 writing data to it. Attachment normally occurs during file open for regular
7 files. Since we are not using file interface to write to the xattr inode,
8 the jinode attach needs to be done manually.
10 Otherwise the following crash occurs in data=ordered mode.
12 BUG: unable to handle kernel NULL pointer dereference at (null)
13 IP: jbd2_journal_file_inode+0x37/0x110
20 CPU: 3 PID: 1877 Comm: python Not tainted 4.12.0-rc1+ #749
21 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
22 task: ffff88010e368980 task.stack: ffffc90000374000
23 RIP: 0010:jbd2_journal_file_inode+0x37/0x110
24 RSP: 0018:ffffc90000377980 EFLAGS: 00010246
25 RAX: 0000000000000000 RBX: ffff880123b06230 RCX: 0000000000280000
26 RDX: 0000000000000006 RSI: 0000000000000000 RDI: ffff88012c8585d0
27 RBP: ffffc900003779b0 R08: 0000000000000202 R09: 0000000000000001
28 R10: 0000000000000000 R11: 0000000000000400 R12: ffff8801111f81c0
29 R13: ffff88013b2b6800 R14: ffffc90000377ab0 R15: 0000000000000001
30 FS: 00007f0c99b77740(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000
31 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
32 CR2: 0000000000000000 CR3: 0000000136d91000 CR4: 00000000000006e0
34 jbd2_journal_inode_add_write+0xe/0x10
35 ext4_map_blocks+0x59e/0x620
36 ext4_xattr_set_entry+0x501/0x7d0
37 ext4_xattr_block_set+0x1b2/0x9b0
38 ext4_xattr_set_handle+0x322/0x4f0
39 ext4_xattr_set+0x144/0x1a0
40 ext4_xattr_user_set+0x34/0x40
41 __vfs_setxattr+0x66/0x80
42 __vfs_setxattr_noperm+0x69/0x1c0
43 vfs_setxattr+0xa2/0xb0
45 path_setxattr+0x87/0xb0
47 entry_SYSCALL_64_fastpath+0x18/0xad
49 Signed-off-by: Tahsin Erdogan <tahsin@google.com>
50 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
52 fs/ext4/xattr.c | 6 ++++++
53 1 file changed, 6 insertions(+)
55 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56 index 12210fe87ea3..8e123533315f 100644
59 @@ -826,6 +826,7 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
62 struct inode *ea_inode = NULL;
66 * Let the next inode be the goal, so we try and allocate the EA inode
67 @@ -848,6 +849,11 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle,
69 EXT4_XATTR_INODE_SET_PARENT(ea_inode, inode->i_ino);
70 unlock_new_inode(ea_inode);
71 + err = ext4_inode_attach_jinode(ea_inode);
74 + return ERR_PTR(err);
80 2.13.1.611.g7e3b11ae1-goog