From: masami.hiramatsu.pt@hitachi.com (Masami Hiramatsu)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] kprobes: bugfix: checks kprobes_all_disarmed in unoptimized_kprobe().
Date: Mon, 19 Jan 2015 21:45:34 +0900 [thread overview]
Message-ID: <54BCFC6E.1080007@hitachi.com> (raw)
In-Reply-To: <54BCE8C3.4080903@huawei.com>
(2015/01/19 20:21), Wang Nan wrote:
> On 2015/1/19 17:05, Masami Hiramatsu wrote:
>> Hi Wang,
>>
>> I've found a problem on this patch, since kprobes calls unoptioize_kprobe
>> with kprobes_all_disarmed=true when trying to disable all kprobes, this
>> cause a serious problem.
>>
>> Moreover, I couldn't reproduce your reported bug on my 3.19-rc4 kernel.
>> Could you test it again?
>>
>
> I tested it again based on 3.19-rc5 and found that the problem still exists.
> My testing is based on QEMU.
>
> First I tested my kprobeopt for ARM, then on x86_64. The test results are pasted
> at the bottom of this mail. Commands after 'gdb attaches to QEMU' is my actions
> on a gdb console attached to QEMU; commands after 'inside virtual machine' is
> what I do in Linux run under QEMU.
Thank you for the reporting.
So, now I know what happened, the problem is "debugfs/kprobes/enabled doesn't work
correctly on optimized kprobes". Please make update the patch description.
I also reproduced the bug without gdb.
Here is the log.
----
[root at localhost ~]# cd /sys/kernel/debug/tracing/
[root at localhost tracing]# echo p do_fork+5 > kprobe_events # setup new event
[root at localhost tracing]# echo $$ > set_ftrace_pid # trace only this process
[root at localhost tracing]# echo 1 > events/kprobes/p_do_fork_5/enable # enable it
[root at localhost tracing]# cat trace # check the trace data
# tracer: nop
#
# entries-in-buffer/entries-written: 1/1 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
bash-3883 [006] d... 279.799023: p_do_fork_5: (do_fork+0x5/0x360) # OK, now tracing
[root at localhost tracing]# cat ../kprobes/list
ffffffff810bc1c5 k do_fork+0x5 [OPTIMIZED] # and it is actually optimized
[root at localhost tracing]# echo 0 > ../kprobes/enabled # disable *ALL* kprobes
[root at localhost tracing]# echo > trace # clear events
[root at localhost tracing]# cat trace # this should show empty buffer
# tracer: nop
#
# entries-in-buffer/entries-written: 1/1 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
bash-3883 [006] d... 337.770785: p_do_fork_5: (do_fork+0x5/0x360) # But still tracing!
[root at localhost tracing]# cat trace # Check again
# tracer: nop
#
# entries-in-buffer/entries-written: 2/2 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| | |
bash-3883 [006] d... 337.770785: p_do_fork_5: (do_fork+0x5/0x360)
bash-3883 [006] d... 345.592178: p_do_fork_5: (do_fork+0x5/0x360) # We are tracing!!
So, after global disabling kprobes, ALL kprobes event should be disabled, but not.
OK, I think your first patch is better than the second one, but not enough.
What we should do is use kprobes_all_disarmed for force option like below.
unoptimize_kprobe(p, kprobes_all_disarmed); /* Try to unoptimize */
We also would better to check the flag in unregistering path for skipping unneeded
disarming process when kprobes globally disarmed.
Thank you,
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt at hitachi.com
next prev parent reply other threads:[~2015-01-19 12:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-05 12:32 [PATCH] kprobes: bugfix: force unoptimize when disable kprobes Wang Nan
2015-01-12 11:42 ` Masami Hiramatsu
2015-01-12 12:09 ` [PATCH] kprobes: bugfix: checks kprobes_all_disarmed in unoptimized_kprobe() Wang Nan
2015-01-12 12:52 ` Masami Hiramatsu
2015-01-19 3:04 ` Wang Nan
2015-01-19 9:05 ` Masami Hiramatsu
2015-01-19 11:21 ` Wang Nan
2015-01-19 12:45 ` Masami Hiramatsu [this message]
2015-01-19 12:59 ` Wang Nan
2015-01-20 2:51 ` [PATCH] kprobes: bugfix: makes kprobes/enabled works correctly for optimized kprobes Wang Nan
2015-01-20 7:12 ` Masami Hiramatsu
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=54BCFC6E.1080007@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).