From: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Masami Hiramatsu <mhiramat@kernel.org>,
"Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
"David S. Miller" <davem@davemloft.net>
Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: kernel hangs when kprobe memcpy
Date: Wed, 11 Jan 2023 19:38:03 +0800 [thread overview]
Message-ID: <d179086d-78d8-d0e3-e113-9072cffa55f4@loongson.cn> (raw)
Hi all,
(1) I have the following test environment, kernel hangs when kprobe memcpy:
system: x86_64 fedora 36
kernel version: Linux 5.7 (compile and update)
test case: modprobe kprobe_example symbol="memcpy" (CONFIG_SAMPLE_KPROBES=m)
In order to fix build errors, it needs to unset CONFIG_NFP and do the
following changes:
commit 52a9dab6d892 ("libsubcmd: Fix use-after-free for realloc(..., 0)")
commit de979c83574a ("x86/entry: Build thunk_$(BITS) only if
CONFIG_PREEMPTION=y")
(2) Using the latest upstream mainline kernel, no hang problem due to the
commit e3a9e681adb7 ("x86/entry: Fixup bad_iret vs noinstr") to prohibit
probing memcpy which is put into the .noinstr.text section.
# modprobe kprobe_example symbol="memcpy"
modprobe: ERROR: could not insert 'kprobe_example': Invalid argument
In my opinion, according to the commit message, the above commit is not
intended to fix the memcpy hang problem, the problem was fixed by accident.
(3) If make handler_pre() and handler_post() as empty functions in the 5.7
kernel code, the above hang problem does not exist.
diff --git a/samples/kprobes/kprobe_example.c
b/samples/kprobes/kprobe_example.c
index fd346f58ddba..c194171d8a46 100644
--- a/samples/kprobes/kprobe_example.c
+++ b/samples/kprobes/kprobe_example.c
@@ -28,8 +28,6 @@ static struct kprobe kp = {
static int __kprobes handler_pre(struct kprobe *p, struct pt_regs *regs)
{
#ifdef CONFIG_X86
- pr_info("<%s> p->addr = 0x%p, ip = %lx, flags = 0x%lx\n",
- p->symbol_name, p->addr, regs->ip, regs->flags);
#endif
#ifdef CONFIG_PPC
pr_info("<%s> p->addr = 0x%p, nip = 0x%lx, msr = 0x%lx\n",
@@ -65,8 +63,6 @@ static void __kprobes handler_post(struct kprobe *p,
struct pt_regs *regs,
unsigned long flags)
{
#ifdef CONFIG_X86
- pr_info("<%s> p->addr = 0x%p, flags = 0x%lx\n",
- p->symbol_name, p->addr, regs->flags);
#endif
#ifdef CONFIG_PPC
pr_info("<%s> p->addr = 0x%p, msr = 0x%lx\n",
I want to know what is the real reason of the hang problem when kprobe
memcpy,
I guess it may be kprobe recursion, what do you think? Thank you.
By the way, kprobe memset has no problem whether or not handler_pre() and
handler_post() are empty functions.
Thanks,
Tiezhu
next reply other threads:[~2023-01-11 11:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 11:38 Tiezhu Yang [this message]
2023-01-12 13:32 ` Tiezhu Yang
2023-01-12 14:36 ` Masami Hiramatsu
2023-01-13 6:26 ` Tiezhu Yang
2023-01-14 5:38 ` Masami Hiramatsu
2023-01-14 6:53 ` Tiezhu Yang
2023-01-14 13:45 ` Masami Hiramatsu
2023-01-16 6:41 ` Masami Hiramatsu
2023-01-16 13:30 ` Tiezhu Yang
2023-01-31 3:38 ` Tiezhu Yang
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=d179086d-78d8-d0e3-e113-9072cffa55f4@loongson.cn \
--to=yangtiezhu@loongson.cn \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen.n.rao@linux.ibm.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
all inboxes | Powered by JetHome®