From: Masami Hiramatsu <mhiramat@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Nick Piggin <npiggin@suse.de>,
LKML <linux-kernel@vger.kernel.org>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Jim Keniston <jkenisto@us.ibm.com>,
systemtap-ml <systemtap@sources.redhat.com>,
"Frank Ch. Eigler" <fche@redhat.com>
Subject: Re: [BUG][kprobes][vunmap?]: kprobes may cause memory corruption
Date: Wed, 28 Jan 2009 13:13:14 -0500 [thread overview]
Message-ID: <4980A03A.2030400@redhat.com> (raw)
In-Reply-To: <49809CCE.40409@redhat.com>
Masami Hiramatsu wrote:
> Mathieu Desnoyers wrote:
>> * Masami Hiramatsu (mhiramat@redhat.com) wrote:
>>> Mathieu Desnoyers wrote:
> [...]
>>>> All this called in a loop. This would help isolating the "vmap" part of
>>>> the issue. If this test is not enough, then we should maybe try
>>>> something like this in a kernel module (which does what text_poke does
>>>> with vmalloc, more or less) in a loop :
>>>>
>>>> char somedata[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
>>>> char copydata[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
>>> Should both of them have PAGE_SIZE*2?
>>>
>> Yes.
>>
>>>> void test_vmap(void)
>>>> }
>>>> struct page *pages[2];
>>>> char *vaddr;
>>>> int i;
>>>>
>>>> for (i = 0; i < 2 * PAGE_SIZE; i++)
>>>> copydata[i] = somedata[i];
>>>> page[0] = virt_to_page(&somedata);
>>>> BUG_ON(!page[0]);
>>>> page[1] = virt_to_page(&somedata + PAGE_SIZE);
>>>> BUG_ON(!page[1]);
>
> Oops, these should be vmalloc_to_page(), shouldn't it?
>
>>>> vaddr = vmap(pages, 2, VM_MAP, PAGE_KERNEL);
>>>> BUG_ON(!vaddr);
>>>>
>>>> for (i = 0; i < 2 * PAGE_SIZE; i++)
>>>> vaddr[i] = copydata[i] + 1;
>>>>
>>>> vunmap(vaddr);
>>>>
>>>> for (i = 0; i < 2 * PAGE_SIZE; i++)
>>>> BUG_ON(somedata[i] != copydata[i] + 1);
>>>> }
>>> Hmm, when I ran above code, it hit the last BUG_ON().
>>> I checked that somedata[i] didn't updated.
>>>
>> Do you hit the BUG_ON after the first loop ?
>
> At the first loop, it hit the BUG_ON.
>
>>>> Given you don't seem to have hit the
>>>> for (i = 0; i < len; i++)
>>>> BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
>>>> test at the end of text_poke,
>>> However, when I ran kprobe-based test, it doesn't hit the BUG_ON()
>>> in text_poke().
>>>
>> The variable declarations should have been 2*PAGE_SIZE, hopefully you
>> fixed them.
>
> Sure,
>
>> There is also a sync_core() in text_poke. It should not matter, but
>> maybe that could help ?
>
> Adding sync_core() could not help me... anyway, I'll try again
> with using vmalloc_to_page().
Hmm, using vmalloc_to_page() works fine... the test didn't hit any BUG_ON.
>
>>>> I suspect the write through the vmapped
>>>> area is correctly done, but that the problem may lay in the mm layer.
>>>> Maybe it's running out of pre-allocated vmap areas or something like
>>>> this ?
>>> I haven't seen vmalloc failure message on 2.6.29-rc2.
>>>
>> It could be because the available vmalloc space is slightly higher.
>> Looking into the lazy vunmap threshold would be useful.
>>
>> You could also try with loop values higher than 400.
I also tested with 1000 loops, but nothing happened.
Thank you,
>
> OK, Thanks,
>
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
prev parent reply other threads:[~2009-01-28 18:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-28 2:32 [BUG][kprobes][vunmap?]: kprobes may cause memory corruption Masami Hiramatsu
2009-01-28 2:39 ` [PATCH][bugfix?][kprobes][vunmap?]: use vm_map_ram() in text_poke() Masami Hiramatsu
2009-01-28 5:09 ` [BUG][kprobes][vunmap?]: kprobes may cause memory corruption Masami Hiramatsu
2009-01-28 15:48 ` Mathieu Desnoyers
2009-01-28 16:22 ` Mathieu Desnoyers
2009-01-28 16:59 ` Masami Hiramatsu
2009-01-28 17:13 ` Mathieu Desnoyers
2009-01-28 17:58 ` Masami Hiramatsu
2009-01-28 18:10 ` Mathieu Desnoyers
2009-02-05 22:12 ` [BUGFIX][PATCH -rc/-mm] prevent kprobes from catching spurious page faults Masami Hiramatsu
2009-02-05 23:57 ` Ingo Molnar
2009-02-06 1:13 ` Mathieu Desnoyers
2009-02-06 2:04 ` Ingo Molnar
2009-02-06 2:05 ` Ingo Molnar
2009-02-06 16:30 ` Masami Hiramatsu
2009-02-06 15:57 ` Masami Hiramatsu
2009-03-16 22:57 ` [BUGFIX][PATCH] prevent boosting kprobes on exception address Masami Hiramatsu
2009-01-28 18:13 ` Masami Hiramatsu [this message]
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=4980A03A.2030400@redhat.com \
--to=mhiramat@redhat.com \
--cc=ananth@in.ibm.com \
--cc=fche@redhat.com \
--cc=jkenisto@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=npiggin@suse.de \
--cc=systemtap@sources.redhat.com \
/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