Re: [PATCH] uprobes: Fix NULL pointer dereference in hprobe_expire()

Oleg Nesterov <[email protected]> Wed, 29 Jul 2026 18:02:35 +0200
Newsgroups org.kernel.vger.linux-trace-kernel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users,org.kernel.vger.stable
Message-ID <[email protected]>
On 07/29, Breno Leitao wrote:
>
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -832,7 +832,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;

Well, looks "obviously correct". At least the current code is obviously
wrong, it even checks uprobe != NULL 3 lines above.

Andrii ?

Acked-by: Oleg Nesterov <[email protected]>