kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* A question about kprobe/kretprobe and kmalloc/kzalloc
@ 2016-12-21 11:35 zerons
  2016-12-22  2:30 ` zerons
  0 siblings, 1 reply; 2+ messages in thread
From: zerons @ 2016-12-21 11:35 UTC (permalink / raw)
  To: kernelnewbies

Hi everyone.

I wrote a kernel module to test something. The module
uses kprobe and kretprobe, here is a bug I met today.

The pre_handler of kprobe, calls `do_something`. The probed
instructions are in the middle of a function.
The entry_handler of kretprobe, also calls `do_something`.
`do_something` calls `kmalloc`+`memset`.

Back to userspace, when I have all the functions probed,
then the test program cause a high CPU usage, and the
keyboard doesn't work. The system does not panic when
I set softlockup_panic=1.

If `do_something` is called by entry_handler of kretprobe,
the module works fine.
The bug happens when `do_something` called by the pre_handler
of kprobe.

So I use "#if 0" to locate the bug. It turns out to
be `kmalloc`+`memset`. When I change that to `kzalloc`,
problem solved.

Then I get confused.
`kzalloc` just calls `kmalloc` with a `__GFP_ZERO`.
Why the bug only happens when pre_handler of kprobe gets called?

Is it necessary to post the source code here? Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-12-22  2:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-21 11:35 A question about kprobe/kretprobe and kmalloc/kzalloc zerons
2016-12-22  2:30 ` zerons

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).