kernel-fxtec-pro1x/drivers/oprofile
Robert Richter 750d857c68 oprofile: fix crash when accessing freed task structs
This patch fixes a crash during shutdown reported below. The crash is
caused by accessing already freed task structs. The fix changes the
order for registering and unregistering notifier callbacks.

All notifiers must be initialized before buffers start working. To
stop buffer synchronization we cancel all workqueues, unregister the
notifier callback and then flush all buffers. After all of this we
finally can free all tasks listed.

This should avoid accessing freed tasks.

On 22.07.10 01:14:40, Benjamin Herrenschmidt wrote:

> So the initial observation is a spinlock bad magic followed by a crash
> in the spinlock debug code:
>
> [ 1541.586531] BUG: spinlock bad magic on CPU#5, events/5/136
> [ 1541.597564] Unable to handle kernel paging request for data at address 0x6b6b6b6b6b6b6d03
>
> Backtrace looks like:
>
>       spin_bug+0x74/0xd4
>       ._raw_spin_lock+0x48/0x184
>       ._spin_lock+0x10/0x24
>       .get_task_mm+0x28/0x8c
>       .sync_buffer+0x1b4/0x598
>       .wq_sync_buffer+0xa0/0xdc
>       .worker_thread+0x1d8/0x2a8
>       .kthread+0xa8/0xb4
>       .kernel_thread+0x54/0x70
>
> So we are accessing a freed task struct in the work queue when
> processing the samples.

Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: stable@kernel.org
Signed-off-by: Robert Richter <robert.richter@amd.com>
2010-08-25 09:09:09 +02:00
..
buffer_sync.c oprofile: fix crash when accessing freed task structs 2010-08-25 09:09:09 +02:00
buffer_sync.h cpumask: modifiy oprofile initialization 2009-01-22 14:37:06 +01:00
cpu_buffer.c oprofile: fix crash when accessing freed task structs 2010-08-25 09:09:09 +02:00
cpu_buffer.h percpu: make percpu symbols in oprofile unique 2009-10-29 22:34:13 +09:00
event_buffer.c oprofile: make event buffer nonseekable 2010-07-26 10:58:24 +02:00
event_buffer.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile 2008-10-23 10:05:40 -07:00
oprof.c oprofile: convert oprofile from timer_hook to hrtimer 2010-03-02 17:03:20 +01:00
oprof.h oprofile: convert oprofile from timer_hook to hrtimer 2010-03-02 17:03:20 +01:00
oprofile_files.c oprofile: Remove oprofile_multiplexing_init() 2009-07-20 16:43:19 +02:00
oprofile_stats.c percpu: make percpu symbols in oprofile unique 2009-10-29 22:34:13 +09:00
oprofile_stats.h oprofile: Adding switch counter to oprofile statistic variables 2009-07-20 16:43:21 +02:00
oprofilefs.c const: mark remaining super_operations const 2009-09-22 07:17:24 -07:00
timer_int.c oprofile: convert oprofile from timer_hook to hrtimer 2010-03-02 17:03:20 +01:00