This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH -tip v14 03/12] kprobes: checks probe address is instruction boudary on x86
- From: Masami Hiramatsu <mhiramat at redhat dot com>
- To: Frederic Weisbecker <fweisbec at gmail dot com>
- Cc: Ingo Molnar <mingo at elte dot hu>, Steven Rostedt <rostedt at goodmis dot org>, lkml <linux-kernel at vger dot kernel dot org>, systemtap <systemtap at sources dot redhat dot com>, kvm <kvm at vger dot kernel dot org>, DLE <dle-develop at lists dot sourceforge dot net>, Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>, Avi Kivity <avi at redhat dot com>, Andi Kleen <ak at linux dot intel dot com>, Christoph Hellwig <hch at infradead dot org>, "Frank Ch. Eigler" <fche at redhat dot com>, "H. Peter Anvin" <hpa at zytor dot com>, Jason Baron <jbaron at redhat dot com>, Jim Keniston <jkenisto at us dot ibm dot com>, "K.Prasad" <prasad at linux dot vnet dot ibm dot com>, Lai Jiangshan <laijs at cn dot fujitsu dot com>, Li Zefan <lizf at cn dot fujitsu dot com>, PrzemysÅawPaweÅczyk <przemyslaw at pawelczyk dot it>, Roland McGrath <roland at redhat dot com>, Sam Ravnborg <sam at ravnborg dot org>, Srikar Dronamraju <srikar at linux dot vnet dot ibm dot com>, Tom Zanussi <tzanussi at gmail dot com>, Vegard Nossum <vegard dot nossum at gmail dot com>
- Date: Tue, 18 Aug 2009 20:19:33 -0400
- Subject: Re: [PATCH -tip v14 03/12] kprobes: checks probe address is instruction boudary on x86
- References: <20090813203403.31965.20973.stgit@localhost.localdomain> <20090813203428.31965.21939.stgit@localhost.localdomain> <20090818230340.GF5231@nowhere> <4A8B3693.9000301@redhat.com> <20090818234341.GG5231@nowhere>
Frederic Weisbecker wrote:
> On Tue, Aug 18, 2009 at 07:17:39PM -0400, Masami Hiramatsu wrote:
>> Frederic Weisbecker wrote:
>>>> + while (addr < paddr) {
>>>> + kernel_insn_init(&insn, (void *)addr);
>>>> + insn_get_opcode(&insn);
>>>> +
>>>> + /* Check if the instruction has been modified. */
>>>> + if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) {
>>>> + ret = recover_probed_instruction(buf, addr);
>>>
>>>
>>>
>>> I'm confused about the reason of this recovering. Is it to remove
>>> kprobes behind the current setting one in the current function?
>>
>> No, it recovers just an instruction which is probed by a kprobe,
>> because we need to know the first byte of this instruction for
>> decoding it.
Ah, sorry, it was not accurate. the function recovers an instruction
on the buffer(buf), not on the real kernel text. :)
>>
>> Perhaps we'd better to have more generic interface (text_peek?)
>> for it because another subsystem (e.g. kgdb) may want to insert int3...
>>
>> Thank you,
>
>
> Aah, I see now, it's to keep a sane check of the instructions
> boundaries without int 3 artifacts in the middle.
>
> But in that case, you should re-arm the breakpoint after your
> check, right?
>
> Or may be you could do the check without repatching?
Yes, it doesn't modify kernel text, just recover an original
instruction from kernel text and backup byte on a buffer.
> May be by doing a copy of insn.opcode.bytes and replacing bytes[0]
> with what a random kprobe has stolen?
Hm, no, this function is protected from other kprobes by kprobe_mutex.
Thank you,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com