Details

[Home]

Issue of the Implementation # F0007

Brief

f2fs: f2fs unmount hangs if f2fs_init_acl() fails during mkdir syscall

Detailed Description

If read_all_xattrs() fails because of insufficient memory when called in the stacktrace

mkdir()->
   f2fs_add_link()->
     init_inode_metadata()->
       f2fs_init_acl()->
         f2fs_get_acl()->
           f2fs_getxattr()->
             read_all_xattrs()
then next BUG_ON() is triggered:
mkdir()->
   f2fs_add_link()->
     init_inode_metadata()->
       remove_inode_page() ->
         f2fs_bug_on(inode->i_blocks != 0 && inode->i_blocks != 1);

This happens because block allocated in

mkdir()->
   f2fs_add_link()->
     init_inode_metadata()->
        make_empty_dir()
for inode is not freed before remove_inode_page() is called. But that function expects only block allocated in
mkdir()->
   f2fs_add_link()->
     init_inode_metadata()->
       new_inode_page()
to be existed.

Reproducing

Problem can be reproduced with simulating fault in read_all_xattrs() when it calls kzalloc().

Example

[  117.863869] kernel BUG at fs/f2fs/node.c:825!
[  117.863870] invalid opcode: 0000 [#1] SMP
[  117.863872] Modules linked in: f2fs kedr_fsim_indicator_common(OF) 
kedr_fsim_indicator_capable(OF)
kedr_fsim_indicator_kmalloc(OF) kedr_fsim_vmm(OF) kedr_fsim_mem_util(OF) 
kedr_fsim_capable(OF)
kedr_fsim_uaccess(OF) kedr_fsim_cmm(OF) kedr_fault_simulation(OF) 
kedr(OF) fuse nf_conntrack_netbios_ns
nf_conntrack_broadcast ipt_MASQUERADE ip6t_REJECT xt_conntrack 
ebtable_nat ebtable_broute bridge stp llc
ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 
nf_nat_ipv6 ip6table_mangle
ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat 
nf_conntrack_ipv4 nf_defrag_ipv4
nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security 
iptable_raw microcode i2c_piix4 parport_pc
e1000 i2c_core parport ata_generic pata_acpi [last unloaded: kedr]
[  117.863894] CPU: 0 PID: 2766 Comm: fs-driver-tests Tainted: 
GF          O 3.13.0fs #2
[  117.863895] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS 
VirtualBox 12/01/2006
[  117.863896] task: ffff8800001b6420 ti: ffff8800111ac000 task.ti: 
ffff8800111ac000
[  117.863897] RIP: 0010:[<ffffffffa01e03bf>] [<ffffffffa01e03bf>] 
remove_inode_page+0xbf/0xd0 [f2fs]
[  117.863901] RSP: 0018:ffff8800111ade08  EFLAGS: 00010202
[  117.863902] RAX: 0000000000000000 RBX: ffff8800125a0c30 RCX: 
ffff8800001b6a78
[  117.863903] RDX: ffff880000000000 RSI: ffffea00004b9780 RDI: 
ffff8800125a0c30
[  117.863903] RBP: ffff8800111ade50 R08: 0000000000000001 R09: 
0000000000000000
[  117.863904] R10: 0000000000000006 R11: 000000000000000f R12: 
ffffea00004b9780
[  117.863905] R13: 0000000000000004 R14: ffffea00004b9780 R15: 
ffffea00004b97c0
[  117.863907] FS:  00007ff92dc9f740(0000) GS:ffff88003fc00000(0000) 
knlGS:0000000000000000
[  117.863908] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  117.863909] CR2: 00007f6673415000 CR3: 000000003c628000 CR4: 
00000000000006f0
[  117.863913] Stack:
[  117.863913]  00000000000041ff ffffea00004b97c0 ffff8800111ade50 
ffffffffa01e9ffa
[  117.863915]  ffffea00004b9780 ffff880000000000 ffff880012e5d000 
0000000000000003
[  117.863917]  ffffea00004b9740 ffff8800111adec0 ffffffffa01d0d20 
ffff880012532948
[  117.863919] Call Trace:
[  117.863922]  [<ffffffffa01e9ffa>] ? f2fs_init_acl+0x10a/0x180 [f2fs]
[  117.863925]  [<ffffffffa01d0d20>] __f2fs_add_link+0x560/0x7c0 [f2fs]
[  117.863928]  [<ffffffffa01d3b8b>] f2fs_mkdir+0xbb/0x150 [f2fs]
[  117.863929]  [<ffffffff811cf4c7>] vfs_mkdir+0xb7/0x160
[  117.863931]  [<ffffffff811d010f>] SyS_mkdir+0x5f/0xc0
[  117.863933]  [<ffffffff8165bf29>] system_call_fastpath+0x16/0x1b
[  117.863934] Code: e6 49 8b 14 24 83 e2 01 74 23 4c 89 e7 89 45 bc e8 
f7 f9 f6 e0 4c 89 e7 e8 ff d1 f7
e0 8b 45 bc 48 83 c4 30 5b 41 5c 41 5d 5d c3 <0f> 0b e8 c8 9d 00 00 66 
2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00
[  117.863953] RIP  [<ffffffffa01e03bf>] remove_inode_page+0xbf/0xd0 [f2fs]
[  117.863956]  RSP <ffff8800111ade08>

Component

linux-kernel 3.13

Accepted

https://lkml.org/lkml/2014/2/6/18
commit

Status

Fixed in kernel 3.15-rc1

[Home]