OOPS in configfs when doing d_delete

From: Jiri Slaby
Date: Mon Feb 21 2011 - 05:20:30 EST


Hi,

when configfs_attach_group fails in configfs_register_subsystem:
dentry = d_alloc(configfs_sb->s_root, &name);
if (dentry) {
d_add(dentry, NULL);

err = configfs_attach_group(sd->s_element, &group->cg_item,
dentry);
if (err) {
d_delete(dentry);
dput(dentry);


d_delete kills the kernel. I don't know what the actual bug is here, but
d_delete looks broken anyway:
spin_lock(&dentry->d_lock);
inode = dentry->d_inode;
isdir = S_ISDIR(inode->i_mode); <======== dereference
if (dentry->d_count == 1) {
if (inode && !spin_trylock(&inode->i_lock)) {
^^^^^ <============= test

It seems like a superfluous test, not a potential null dereference to
me, right?

The oops:
BUG: unable to handle kernel NULL pointer dereference at 00000000000000ba
IP: [<ffffffff81166f64>] d_delete+0x34/0x100
PGD 26108067 PUD 26111067 PMD 0
Oops: 0000 [#1] PREEMPT SMP
last sysfs file: /sys/devices/virtual/tty/digi_ctl255/uevent
CPU 0
Modules linked in: ...
Pid: 6876, comm: modprobe Not tainted 2.6.37-22-desktop #1 /Bochs
RIP: 0010:[<ffffffff81166f64>] [<ffffffff81166f64>] d_delete+0x34/0x100
RSP: 0018:ffff880026123ea8 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff880028beb380 RCX: ffffffffa45c7bc0
RDX: 0000000000000001 RSI: ffff880028beb42d RDI: ffff880028beb388
RBP: ffff880028beb388 R08: 00000000d70f3acb R09: 000000009e367ab8
R10: 0000000000000000 R11: 000000009d377ab8 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000406750
FS: 00007f574dd28700(0000) GS:ffff88003e400000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00000000000000ba CR3: 0000000026002000 CR4: 00000000000006f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process modprobe (pid: 6876, threadinfo ffff880026122000, task
ffff880026dc4440)
Stack:
ffffffffa45c0c80 ffff880028beb380 ffffffffa29204e0 ffffffffa291ca00
0000000000000001 ffffffffffffffef 0000000c9f97db74 ffffffffa45c0c88
ffffffffa45c0c80 ffffffffa45c0948 ffffffffa45d4000 ffffffffa45d4041
Call Trace:
[<ffffffffa291ca00>] configfs_register_subsystem+0x110/0x1d0 [configfs]
[<ffffffffa45d4041>] configfs_example_init+0x41/0x96
[configfs_example_macros]
[<ffffffff810002da>] do_one_initcall+0x3a/0x170
[<ffffffff810963ba>] sys_init_module+0xba/0x210
[<ffffffff81002f8b>] system_call_fastpath+0x16/0x1b
[<00007f574d672d2a>] 0x7f574d672d2a
Code: 89 fb 48 89 6c 24 08 48 8d 6b 08 48 c7 c7 80 22 a0 81 4c 89 64 24
10 e8 cb b6 3b 00 48 89 ef 45 31 e4 e8 c0 b6 3b 00 48 8b 43 10 <0f> b7
80 ba 00 00 00 25 00 f0 00 00 3d 00 40 00 00 8b 03 41 0f
RIP [<ffffffff81166f64>] d_delete+0x34/0x100
RSP <ffff880026123ea8>
CR2: 00000000000000ba

regards,
--
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/