From: Mathieu Desnoyers Date: Thu, 6 Jun 2013 02:54:50 +0000 (-0400) Subject: fix: block instrumentation: NULL pointer dereference X-Git-Tag: v2.1.2~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=94e7e92cd7bc868f351d3e96413539df6a51f5f4;p=lttng-modules.git fix: block instrumentation: NULL pointer dereference This backtrace appears with kernel 3.9.4: [19311.313455] BUG: unable to handle kernel NULL pointer dereference at (null) [19311.316589] IP: [] __event_probe__block_bio+0x8b/0x1a0 [lttng_probe_block] [19311.316589] PGD 41808a067 PUD 4190a3067 PMD 0 [19311.316589] Oops: 0000 [#1] PREEMPT SMP [19311.316589] Modules linked in: lttng_probe_writeback(O) lttng_probe_workqueue(O) lttng_probe_vmscan(O) lttng_probe_udp(O) lm [19311.316589] CPU 4 [19311.316589] Pid: 1423, comm: kjournald Tainted: G O 3.9.4-trace-test #143 Supermicro X7DAL/X7DAL [19311.316589] RIP: 0010:[] [] __event_probe__block_bio+0x8b/0x1a0 [lttng_probe_block] [19311.316589] RSP: 0018:ffff88041c0d5aa8 EFLAGS: 00010246 [19311.316589] RAX: 0000000000000000 RBX: ffff88041a994c00 RCX: ffff88041b610800 [19311.316589] RDX: 0000000000000004 RSI: ffff88041c0d5b00 RDI: ffff88041c0d5ab0 [19311.316589] RBP: ffff88041c0d5b18 R08: fffffffffffc0000 R09: 0000000000000000 [19311.316589] R10: ffff88041a9947e8 R11: 0000000000000001 R12: ffff880419252c18 [19311.316589] R13: ffff88041c9e0a48 R14: ffff88041749bd10 R15: ffff88041749bd20 [19311.316589] FS: 0000000000000000(0000) GS:ffff88042fd00000(0000) knlGS:0000000000000000 [19311.316589] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [19311.316589] CR2: 0000000000000000 CR3: 0000000417a0a000 CR4: 00000000000007e0 [19311.316589] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [19311.316589] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [19311.316589] Process kjournald (pid: 1423, threadinfo ffff88041c0d4000, task ffff88041daa0000) [19311.316589] Stack: [19311.316589] 0000000000000000 ffff88041c3e4000 ffff880408987518 0000000000000024 [19311.316589] 0000000400000001 ffff88042fd19e30 000000000000002a 00000000000126c1 [19311.316589] 00000000000126bb 0000119043fa4efc ffff880400000000 0000000000000246 [19311.316589] Call Trace: [19311.316589] [] bio_attempt_back_merge+0xfb/0x1e0 [19311.316589] [] blk_queue_bio+0x43f/0x570 [19311.316589] [] generic_make_request+0xca/0x100 [19311.316589] [] raid1_unplug+0x12e/0x170 [19311.316589] [] blk_flush_plug_list+0x9c/0x210 [19311.316589] [] blk_finish_plug+0x18/0x50 [19311.316589] [] journal_commit_transaction+0x728/0x1f30 [19311.316589] [] ? try_to_del_timer_sync+0x53/0x70 [19311.316589] [] ? del_timer_sync+0x5/0xd0 [19311.316589] [] kjournald+0xed/0x290 [19311.316589] [] ? __init_waitqueue_head+0x60/0x60 [19311.316589] [] ? commit_timeout+0x10/0x10 [19311.316589] [] kthread+0xdb/0xe0 [19311.316589] [] ? _raw_spin_unlock_irq+0x30/0x60 [19311.316589] [] ? __init_kthread_worker+0x70/0x70 [19311.316589] [] ret_from_fork+0x7c/0xb0 [19311.316589] [] ? __init_kthread_worker+0x70/0x70 Fixes #559 Signed-off-by: Mathieu Desnoyers --- diff --git a/instrumentation/events/lttng-module/block.h b/instrumentation/events/lttng-module/block.h index 6782cbbe..16043a01 100644 --- a/instrumentation/events/lttng-module/block.h +++ b/instrumentation/events/lttng-module/block.h @@ -365,7 +365,7 @@ DECLARE_EVENT_CLASS(block_bio, ), TP_fast_assign( - tp_assign(dev, bio->bi_bdev->bd_dev) + tp_assign(dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0) tp_assign(sector, bio->bi_sector) tp_assign(nr_sector, bio->bi_size >> 9) blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)