From: "tip-bot2 for Breno Leitao" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Breno Leitao <leitao@debian.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Oleg Nesterov <oleg@redhat.com>,
Andrii Nakryiko <andrii@kernel.org>,
stable@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org
Subject: [tip: perf/urgent] uprobes: Fix NULL pointer dereference in hprobe_expire()
Date: Fri, 31 Jul 2026 08:52:58 -0000 [thread overview]
Message-ID: <178548797804.112641.4838093438132290110.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260729-uprobe-v1-1-61896b87c867@debian.org>
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: cc679d7a6303e84d769f2afcde1fc51c51f127cd
Gitweb: https://git.kernel.org/tip/cc679d7a6303e84d769f2afcde1fc51c51f127cd
Author: Breno Leitao <leitao@debian.org>
AuthorDate: Wed, 29 Jul 2026 07:44:40 -07:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 31 Jul 2026 10:32:19 +02:00
uprobes: Fix NULL pointer dereference in hprobe_expire()
Forking a task that has a pending uretprobe can oops the kernel with a
NULL pointer dereference in the clone() path:
BUG: kernel NULL pointer dereference, address: 0000000000000018
Oops: 0002 [#1] SMP NOPTI
RIP: 0010:hprobe_expire
CR2: 0000000000000018
Call Trace:
uprobe_copy_process
copy_process
kernel_clone
__x64_sys_clone
do_syscall_64
entry_SYSCALL_64_after_hwframe
This was found on real hosts on Meta fleet.
I've got the impression that this is what is happening:
CPU 1 CPU 2 (traced task)
----- -------------------
hit uprobe, prepare_uretprobe():
hprobe LEASED, refcount >= 1
uprobe_unregister()
put_uprobe(): refcount -> 0
fork() -> dup_utask()
hprobe_expire(hprobe, true)
try_get_uprobe() -> NULL
get_uprobe(NULL) <-- Oops
Only take the extra reference when the uprobe is non-NULL; a NULL means
it is gone and is the correct value to return.
Fixes: dd1a7567784e ("uprobes: SRCU-protect uretprobe lifetime (with timeout)")
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260729-uprobe-v1-1-61896b87c867@debian.org
---
kernel/events/uprobes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 4084e92..6300b21 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -830,7 +830,7 @@ static struct uprobe *hprobe_expire(struct hprobe *hprobe, bool get)
if (try_cmpxchg(&hprobe->state, &hstate, uprobe ? HPROBE_STABLE : HPROBE_GONE)) {
/* We won the race, we are the ones to unlock SRCU */
__srcu_read_unlock(&uretprobes_srcu, hprobe->srcu_idx);
- return get ? get_uprobe(uprobe) : uprobe;
+ return get && uprobe ? get_uprobe(uprobe) : uprobe;
}
/*
prev parent reply other threads:[~2026-07-31 8:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-29 14:44 [PATCH] " Breno Leitao
2026-07-29 16:02 ` Oleg Nesterov
2026-07-29 19:31 ` Andrii Nakryiko
2026-07-29 23:54 ` Masami Hiramatsu
2026-07-30 10:38 ` Peter Zijlstra
2026-07-31 0:56 ` Masami Hiramatsu
2026-07-31 8:30 ` Peter Zijlstra
2026-07-31 8:43 ` Oleg Nesterov
2026-07-31 8:51 ` Peter Zijlstra
2026-07-31 8:52 ` tip-bot2 for Breno Leitao [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=178548797804.112641.4838093438132290110.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=andrii@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®