mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum@gmail.com>
To: Alex Chiang <achiang@hp.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
	Ingo Molnar <mingo@elte.hu>,
	jbarnes@virtuousgeek.org, xyzzy@speakeasy.org, djwong@us.ibm.com,
	shimada-yxb@necst.nec.co.jp, rjw@sisk.pl,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 00/11] PCI core learns hotplug
Date: Mon, 9 Mar 2009 21:28:00 +0100	[thread overview]
Message-ID: <19f34abd0903091328q4471bb3he0c6e07fa32a6a1f@mail.gmail.com> (raw)
In-Reply-To: <20090309195250.GQ32589@ldl.fc.hp.com>

2009/3/9 Alex Chiang <achiang@hp.com>:
>> It reproduces reliably if I do this:
>>
>> $ while true; do echo 1 > /sys/bus/pci/devices/0000\:00\:00.0/remove; done
>
> I was going to ask for lspci -v output so that I could see what
> device 0000:00:00.0 might be, but I was able to reproduce
> something similar on my machine.
>
> Can I ask why you're doing the above with a while loop? Just to
> torture the code? Or something else?

Yes, purely for the purpose of torture ;-)

I also found one more use-after-free error using kmemcheck:

[  263.258025] WARNING: kmemcheck: Caught 8-bit read from freed memory
(ffff88003d8f315c)
[  263.266131] 80e1803f0088ffff20d67b81ffffffff0000000000000000000000000d000000
[  263.275104]  f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f f
[  263.284053]                                                          ^
[  263.290696]
[  263.292303] Pid: 881, comm: udevd Not tainted 2.6.29-rc6 #361 945P-A
[  263.298770] RIP: 0010:[<ffffffff811eb501>]  [<ffffffff811eb501>]
kobject_put+0x11/0x60
[  263.306938] RSP: 0018:ffff88003f8bde60  EFLAGS: 00010282
[  263.312367] RAX: 0000000000000001 RBX: ffff88003d8f3120 RCX: 0000000000000000
[  263.319616] RDX: 0000000000000001 RSI: 0000000000000003 RDI: ffff88003d8f3120
[  263.326865] RBP: ffff88003f8bde70 R08: 00000000002ec000 R09: 0000000000000000
[  263.334114] R10: ffff88003d95fdc0 R11: 0000000000000010 R12: ffff88003d946ac0
[  263.341362] R13: ffff88003f80a908 R14: ffff88003f80a908 R15: ffff88003f8adf00
[  263.348613] FS:  0000000000000000(0000) GS:ffff8800019f1000(0063)
knlGS:00000000f7d6c700
[  263.356884] CS:  0010 DS: 002b ES: 002b CR0: 000000008005003b
[  263.362747] CR2: ffff88003f806ea0 CR3: 000000003e44a000 CR4: 00000000000006a0
[  263.369995] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  263.377246] DR3: 0000000000000000 DR6: 00000000ffff4ff0 DR7: 0000000000000400
[  263.384494]  [<ffffffff81125048>] sysfs_schedule_callback_work+0x28/0x40
[  263.391378]  [<ffffffff81055510>] run_workqueue+0x70/0x130
[  263.397049]  [<ffffffff81055677>] worker_thread+0xa7/0x120
[  263.402720]  [<ffffffff810593d9>] kthread+0x49/0x90
[  263.407784]  [<ffffffff8100d45a>] child_rip+0xa/0x20
[  263.412935]  [<ffffffffffffffff>] 0xffffffffffffffff
[  281.464381] NOHZ: local_softirq_pending 01

This is how I triggered it:

# echo 1 > /sys/bus/pci/devices/0000\:00\:00.0/remove
# echo 1 > /sys/bus/pci/rescan
# echo 1 > /sys/bus/pci/rescan
# echo 1 > /sys/bus/pci/devices/0000\:00\:00.0/remove

The line numbers:

$ addr2line -e vmlinux -i ffffffff811eb501 ffffffff81125048
lib/kobject.c:589
fs/sysfs/file.c:677

586 void kobject_put(struct kobject *kobj)
587 {
588         if (kobj) {
589                 if (!kobj->state_initialized)
590                         WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
591                                "initialized, yet kobject_put() is being "
592                                "called.\n", kobject_name(kobj), kobj);
593                 kref_put(&kobj->kref, kobject_release);
594         }
595 }

669 static void sysfs_schedule_callback_work(struct work_struct *work)
670 {
671         struct sysfs_schedule_callback_struct *ss = container_of(work,
672                         struct sysfs_schedule_callback_struct, work);
673
674         (ss->func)(ss->data);
675         kobject_put(ss->kobj);
676         module_put(ss->owner);
677         kfree(ss);
678 }

(The short story: the ss->kobj was already freed when this function was called.)

Hope this helps :-)


Vegard

-- 
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036

  reply	other threads:[~2009-03-09 20:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-09  5:48 Alex Chiang
2009-03-09  5:48 ` [PATCH v3 01/11] PCI: pci_is_root_bus helper Alex Chiang
2009-03-09  5:48 ` [PATCH v3 02/11] PCI: don't scan existing devices Alex Chiang
2009-03-09  5:48 ` [PATCH v3 03/11] PCI: pci_scan_slot() returns newly found devices Alex Chiang
2009-03-09  5:48 ` [PATCH v3 04/11] PCI: always scan child buses Alex Chiang
2009-03-09  5:49 ` [PATCH v3 05/11] PCI: beef up pci_do_scan_bus() Alex Chiang
2009-03-12  9:16   ` Kenji Kaneshige
2009-03-12 23:22     ` Alex Chiang
2009-03-13  9:11       ` Kenji Kaneshige
2009-03-15 16:48         ` Alex Chiang
2009-03-18  8:29           ` Kenji Kaneshige
2009-03-18 20:39             ` Alex Chiang
2009-03-19  2:15               ` Kenji Kaneshige
2009-03-09  5:49 ` [PATCH v3 06/11] PCI: Introduce /sys/bus/pci/rescan Alex Chiang
2009-03-09  5:49 ` [PATCH v3 07/11] PCI: Introduce /sys/bus/pci/devices/.../remove Alex Chiang
2009-03-09 18:52   ` Alex Chiang
2009-03-10 22:37     ` Alex Chiang
2009-03-11  4:08       ` Alex Chiang
2009-03-09  5:49 ` [PATCH v3 08/11] PCI: Introduce /sys/bus/pci/devices/.../rescan Alex Chiang
2009-03-09  5:49 ` [PATCH v3 09/11] PCI Hotplug: restore fakephp interface with complete reimplementation Alex Chiang
2009-03-09  5:49 ` [PATCH v3 10/11] PCI Hotplug: rename legacy_fakephp to fakephp Alex Chiang
2009-03-09  5:49 ` [PATCH v3 11/11] PCI Hotplug: schedule fakephp for feature removal Alex Chiang
2009-03-09 18:51 ` [PATCH v3 00/11] PCI core learns hotplug Alex Chiang
2009-03-09 19:30   ` Vegard Nossum
2009-03-09 19:52     ` Alex Chiang
2009-03-09 20:28       ` Vegard Nossum [this message]
2009-03-09 20:37         ` Alex Chiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19f34abd0903091328q4471bb3he0c6e07fa32a6a1f@mail.gmail.com \
    --to=vegard.nossum@gmail.com \
    --cc=achiang@hp.com \
    --cc=djwong@us.ibm.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    --cc=rjw@sisk.pl \
    --cc=shimada-yxb@necst.nec.co.jp \
    --cc=xyzzy@speakeasy.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®