tracing/uprobe: Fix NULL pointer dereference in trace_uprobe_create()
PATCH 1/2 tracing/uprobe: Fix NULL pointer dereference in trace_uprobe_create()
Just like the case of commit 8b05a3a7503c ("tracing/kprobes: Fix NULL pointer dereference in trace_kprobe_create()"), writing an incorrectly formatted string to uprobe_events can trigger NULL pointer dereference.
Reporeducer:
# echo r > /sys/kernel/debug/tracing/uprobe_events
dmesg:
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 8000000079d12067 P4D 8000000079d12067 PUD 7b7ab067 PMD 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 1903 Comm: bash Not tainted 5.2.0-rc3+ #15 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014 RIP: 0010:strchr+0x0/0x30 Code: c0 eb 0d 84 c9 74 18 48 83 c0 01 48 39 d0 74 0f 0f b6 0c 07 3a 0c 06 74 ea 19 c0 83 c8 01 c3 31 c0 c3 0f 1f 84 00 00 00 00 00 <0f> b6 07 89 f2 40 38 f0 75 0e eb 13 0f b6 47 01 48 83 c RSP: 0018:ffffb55fc0403d10 EFLAGS: 00010293
RAX: ffff993ffb793400 RBX: 0000000000000000 RCX: ffffffffa4852625
RDX: 0000000000000000 RSI: 000000000000002f RDI: 0000000000000000
RBP: ffffb55fc0403dd0 R08: ffff993ffb793400 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13: ffff993ff9cc1668 R14: 0000000000000001 R15: 0000000000000000
FS: 00007f30c5147700(0000) GS:ffff993ffda00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000007b628000 CR4: 00000000000006f0
Call Trace: trace_uprobe_create+0xe6/0xb10 ? __kmalloc_track_caller+0xe6/0x1c0 ? __kmalloc+0xf0/0x1d0 ? trace_uprobe_create+0xb10/0xb10 create_or_delete_trace_uprobe+0x35/0x90 ? trace_uprobe_create+0xb10/0xb10 trace_run_command+0x9c/0xb0 trace_parse_run_command+0xf9/0x1eb ? probes_open+0x80/0x80 __vfs_write+0x43/0x90 vfs_write+0x14a/0x2a0 ksys_write+0xa2/0x170 do_syscall_64+0x7f/0x200 entry_SYSCALL_64_after_hwframe+0x49/0xbe
--- kernel/trace/trace_uprobe.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
kernel/trace/trace_uprobe.c +10 -3
@@ -443,10 +443,17 @@ static int trace_uprobe_create(int argc, const char **argv) ret =0 ; ref_ctr_offset =0 ; -/* argc must be >= 1 */ -if (argv[0 ][0 ] =='r' ) +switch (argv[0 ][0 ]) { +case 'r' : is_return = true; -else if (argv[0 ][0 ] !='p' || argc <2 ) +break ; +case 'p' : +break ; +default : +return -ECANCELED ; + } + +if (argc <2 )return -ECANCELED ;if (argv[0 ][1 ] ==':' )
Signature · 1 line
2.21.0
PATCH 2/2 tracing/uprobe: Fix obsolete comment on trace_uprobe_create()
Commit 0597c49c69d5 ("tracing/uprobes: Use dyn_event framework for uprobe events") cleaned up the usage of trace_uprobe_create(), and the function has been no longer used for removing uprobe/uretprobe.
--- kernel/trace/trace_uprobe.c | 2 -- 1 file changed, 2 deletions(-)
kernel/trace/trace_uprobe.c +0 -2
@@ -426,8 +426,6 @@ static int register_trace_uprobe(struct trace_uprobe *tu)/* * Argument syntax: * - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] -* -* - Remove uprobe: -:[GRP/]EVENT */ static int trace_uprobe_create (int argc,const char **argv) {
Signature · 1 line
2.21.0
Re: [PATCH 2/2] tracing/uprobe: Fix obsolete comment on trace_uprobe_create()
Quoted 4 lines · Eiichi Tsukata
Commit
0597c49c69d5("tracing/uprobes: Usedyn_eventframework for uprobe events") cleaned up the usage oftrace_uprobe_create(), and the function has been no longer used for removing uprobe/uretprobe.
Agree
Quoted 21 lines
Signed-off-by Eiichi Tsukata <[email protected]>--- kernel/trace/trace_uprobe.c | 2 -- 1 file changed, 2 deletions(-)kernel/trace/trace_uprobe.c +0
-2@@ -426,8 +426,6 @@ static int register_trace_uprobe(struct trace_uprobe *tu)/* * Argument syntax: * - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] -* -* - Remove uprobe: -:[GRP/]EVENT */ static int trace_uprobe_create (int argc,const char **argv) {Signature · 1 line
2.21.0
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Quoted 45 lines · Eiichi Tsukata
Just like the case of commit
8b05a3a7503c("tracing/kprobes: Fix NULL pointer dereference intrace_kprobe_create()"), writing an incorrectly formatted string touprobe_eventscan trigger NULL pointer dereference.Reporeducer:
# echo r > /sys/kernel/debug/tracing/uprobe_eventsdmesg:
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 8000000079d12067 P4D 8000000079d12067 PUD 7b7ab067 PMD 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 1903 Comm: bash Not tainted 5.2.0-rc3+ #15 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014 RIP: 0010:strchr+0x0/0x30 Code: c0 eb 0d 84 c9 74 18 48 83 c0 01 48 39 d0 74 0f 0f b6 0c 07 3a 0c 06 74 ea 19 c0 83 c8 01 c3 31 c0 c3 0f 1f 84 00 00 00 00 00 <0f> b6 07 89 f2 40 38 f0 75 0e eb 13 0f b6 47 01 48 83 c RSP: 0018:ffffb55fc0403d10 EFLAGS: 00010293RAX:
ffff993ffb793400RBX: 0000000000000000 RCX:ffffffffa4852625
RDX: 0000000000000000 RSI:000000000000002fRDI: 0000000000000000
RBP:ffffb55fc0403dd0R08:ffff993ffb793400R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13:ffff993ff9cc1668R14: 0000000000000001 R15: 0000000000000000
FS: 00007f30c5147700(0000) GS:ffff993ffda00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3:000000007b628000CR4:00000000000006f0Call Trace: trace_uprobe_create+0xe6/0xb10 ? __kmalloc_track_caller+0xe6/0x1c0 ? __kmalloc+0xf0/0x1d0 ? trace_uprobe_create+0xb10/0xb10 create_or_delete_trace_uprobe+0x35/0x90 ? trace_uprobe_create+0xb10/0xb10 trace_run_command+0x9c/0xb0 trace_parse_run_command+0xf9/0x1eb ? probes_open+0x80/0x80 __vfs_write+0x43/0x90 vfs_write+0x14a/0x2a0 ksys_write+0xa2/0x170 do_syscall_64+0x7f/0x200 entry_SYSCALL_64_after_hwframe+0x49/0xbe
Quoted 6 lines
Fixes 0597c49c69d5 ("tracing/uprobes: Use dyn_event framework for uprobe events")Signed-off-by Eiichi Tsukata <[email protected]>--- kernel/trace/trace_uprobe.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
Good Catch.
Signature · 2 lines
Thanks and Regards Srikar Dronamraju
Quoted 45 lines · On Fri, 14 Jun 2019 16:40:25 +0900 Eiichi Tsukata <[email protected]> wrote:
Just like the case of commit
8b05a3a7503c("tracing/kprobes: Fix NULL pointer dereference intrace_kprobe_create()"), writing an incorrectly formatted string touprobe_eventscan trigger NULL pointer dereference.Reporeducer:
# echo r > /sys/kernel/debug/tracing/uprobe_eventsdmesg:
BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 8000000079d12067 P4D 8000000079d12067 PUD 7b7ab067 PMD 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 1903 Comm: bash Not tainted 5.2.0-rc3+ #15 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014 RIP: 0010:strchr+0x0/0x30 Code: c0 eb 0d 84 c9 74 18 48 83 c0 01 48 39 d0 74 0f 0f b6 0c 07 3a 0c 06 74 ea 19 c0 83 c8 01 c3 31 c0 c3 0f 1f 84 00 00 00 00 00 <0f> b6 07 89 f2 40 38 f0 75 0e eb 13 0f b6 47 01 48 83 c RSP: 0018:ffffb55fc0403d10 EFLAGS: 00010293RAX:
ffff993ffb793400RBX: 0000000000000000 RCX:ffffffffa4852625
RDX: 0000000000000000 RSI:000000000000002fRDI: 0000000000000000
RBP:ffffb55fc0403dd0R08:ffff993ffb793400R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
R13:ffff993ff9cc1668R14: 0000000000000001 R15: 0000000000000000
FS: 00007f30c5147700(0000) GS:ffff993ffda00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3:000000007b628000CR4:00000000000006f0Call Trace: trace_uprobe_create+0xe6/0xb10 ? __kmalloc_track_caller+0xe6/0x1c0 ? __kmalloc+0xf0/0x1d0 ? trace_uprobe_create+0xb10/0xb10 create_or_delete_trace_uprobe+0x35/0x90 ? trace_uprobe_create+0xb10/0xb10 trace_run_command+0x9c/0xb0 trace_parse_run_command+0xf9/0x1eb ? probes_open+0x80/0x80 __vfs_write+0x43/0x90 vfs_write+0x14a/0x2a0 ksys_write+0xa2/0x170 do_syscall_64+0x7f/0x200 entry_SYSCALL_64_after_hwframe+0x49/0xbe
Quoted 2 lines
Fixes 0597c49c69d5 ("tracing/uprobes: Use dyn_event framework for uprobe events")Signed-off-by Eiichi Tsukata <[email protected]>
Sorry, I missed this fix.
Steve, could you pick this as an urgent fix?
Thank you!
Quoted 32 lines
--- kernel/trace/trace_uprobe.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)kernel/trace/trace_uprobe.c +10
-3@@ -443,10 +443,17 @@ static int trace_uprobe_create(int argc, const char **argv) ret =0 ; ref_ctr_offset =0 ; -/* argc must be >= 1 */ -if (argv[0 ][0 ] =='r' ) +switch (argv[0 ][0 ]) { +case 'r' : is_return = true; -else if (argv[0 ][0 ] !='p' || argc <2 ) +break ; +case 'p' : +break ; +default : +return -ECANCELED ; + } + +if (argc <2 )return -ECANCELED ;if (argv[0 ][1 ] ==':' )Signature · 1 line
2.21.0
Signature · 1 line
Masami Hiramatsu <[email protected]>