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 18:12:00 -0000 [thread overview]
Message-ID: <49809CCE.40409@redhat.com> (raw)
In-Reply-To: <20090128171331.GA9006@Krystal>
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().
>>> 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.
OK, Thanks,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
next prev parent reply other threads:[~2009-01-28 17:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-28 5:10 Masami Hiramatsu
2009-01-28 15:48 ` [PATCH][bugfix?][kprobes][vunmap?]: use vm_map_ram() in text_poke() Masami Hiramatsu
2009-01-28 16:23 ` [BUG][kprobes][vunmap?]: kprobes may cause memory corruption Masami Hiramatsu
2009-01-28 16:52 ` Mathieu Desnoyers
2009-01-28 16:59 ` Mathieu Desnoyers
2009-01-28 17:58 ` Masami Hiramatsu
2009-01-28 18:11 ` Mathieu Desnoyers
2009-01-28 18:12 ` Masami Hiramatsu [this message]
2009-01-28 18:13 ` Mathieu Desnoyers
2009-02-06 0:02 ` [BUGFIX][PATCH -rc/-mm] prevent kprobes from catching spurious page faults Masami Hiramatsu
2009-02-06 0:29 ` Ingo Molnar
2009-02-06 1:44 ` Mathieu Desnoyers
2009-02-06 3:00 ` Ingo Molnar
2009-02-06 3:42 ` Ingo Molnar
2009-02-06 20:53 ` Masami Hiramatsu
2009-02-06 16:30 ` Masami Hiramatsu
2009-03-17 13:22 ` [BUGFIX][PATCH] prevent boosting kprobes on exception address Masami Hiramatsu
2009-01-28 20:21 ` [BUG][kprobes][vunmap?]: kprobes may cause memory corruption 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=49809CCE.40409@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).