kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: sironhide0null@gmail.com (zerons)
To: kernelnewbies@lists.kernelnewbies.org
Subject: A question about kprobe/kretprobe and kmalloc/kzalloc
Date: Wed, 21 Dec 2016 19:35:57 +0800	[thread overview]
Message-ID: <6e25ab27-c4e9-a452-1107-5cd9640e3a2d@gmail.com> (raw)

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.

             reply	other threads:[~2016-12-21 11:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21 11:35 zerons [this message]
2016-12-22  2:30 ` A question about kprobe/kretprobe and kmalloc/kzalloc zerons

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=6e25ab27-c4e9-a452-1107-5cd9640e3a2d@gmail.com \
    --to=sironhide0null@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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).