1 ext4: lock inode before calling ext4_orphan_add()
3 From: Tahsin Erdogan <tahsin@google.com>
5 ext4_orphan_add() requires caller to be holding the inode lock.
6 Add missing lock statements.
8 WARNING: CPU: 3 PID: 1806 at fs/ext4/namei.c:2731 ext4_orphan_add+0x4e/0x240
9 CPU: 3 PID: 1806 Comm: python Not tainted 4.12.0-rc1+ #746
10 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
11 task: ffff880135d466c0 task.stack: ffffc900014b0000
12 RIP: 0010:ext4_orphan_add+0x4e/0x240
13 RSP: 0018:ffffc900014b3d50 EFLAGS: 00010246
14 RAX: 0000000000000000 RBX: ffff8801348fe1f0 RCX: ffffc900014b3c64
15 RDX: 0000000000000000 RSI: ffff8801348fe1f0 RDI: ffff8801348fe1f0
16 RBP: ffffc900014b3da0 R08: 0000000000000000 R09: ffffffff80e82025
17 R10: 0000000000004692 R11: 000000000000468d R12: ffff880137598000
18 R13: ffff880137217000 R14: ffff880134ac58d0 R15: 0000000000000000
19 FS: 00007fc50f09e740(0000) GS:ffff88013fd80000(0000) knlGS:0000000000000000
20 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
21 CR2: 00000000008bc2e0 CR3: 00000001375ac000 CR4: 00000000000006e0
23 ext4_xattr_inode_orphan_add.constprop.19+0x9d/0xf0
24 ext4_xattr_delete_inode+0x1c4/0x2f0
25 ext4_evict_inode+0x15a/0x7f0
28 do_unlinkat+0x172/0x290
30 entry_SYSCALL_64_fastpath+0x18/0xad
32 Signed-off-by: Tahsin Erdogan <tahsin@google.com>
33 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
35 fs/ext4/xattr.c | 2 ++
36 1 file changed, 2 insertions(+)
38 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
39 index 26d2705950a5..09ba0137d529 100644
42 @@ -1963,7 +1963,9 @@ ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode,
43 lea_ino_array->xia_inodes[idx], &error);
46 + inode_lock(ea_inode);
47 ext4_orphan_add(handle, ea_inode);
48 + inode_unlock(ea_inode);
49 /* the inode's i_count will be released by caller */
53 2.13.1.611.g7e3b11ae1-goog