From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0132623BD06; Sat, 12 Sep 2026 14:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789224414; cv=none; b=uaZrRwFuTrhOH2wBp/Fw7FItHLF4g2blZ0ySfdx7ILJ6nlRy3BQKleSgTDSM/R1IMCUsvOvnGjcza/vt3AzU69AZRv1vzMwar2P5uUwC+AFQrmsbmoUV+yDfhr/kjxrfkV4wj5gxqoA713+6oWxHZpByLgYNDm8cqGI74mzlYE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789224414; c=relaxed/simple; bh=1eisufTeOvDt/Ik5J1h71iMzya7PSDzPRwQUpAqgPwA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SPpsunBERZAatqjctEqtYpndlP/2hLGEBojD+1BIKFEHcJ2kE/h8KN4UIcxqi03ZdXV0iyumk+9l9hNmNNA1BYnZ2NDrWbm7x80jWSfnR5MyTCvUvVgMRvhIkstJ2GXehVVp5uIdmm8JLsuXEDg5bsZ1kd8/tW0dvqgGSiKdYQY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TbyaH4pG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TbyaH4pG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFACC1F000FF; Sat, 12 Sep 2026 14:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789224412; bh=epPdnBvaJBbpmk62BbI3cQjGtOJPZS2MCmwTxQQYpaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TbyaH4pGgiCfa9F87TUpI0JugdWQNwI8raujI8GuzjhSvM5UdklzGaSd1JSWSybMl uRSglgQp7SQs4xn82xmJRPHL0i3R+y+9fsasnqrrgskNpmVXeIdFcYTylerqN3edOX k7YTNgj5SyGbf7TYo411YJXQRgm+aCkYqryo3VRA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot , Adrian Hunter , Arnaldo Carvalho de Melo , Namhyung Kim , Sasha Levin Subject: [PATCH 6.6 0987/1424] perf machine: Fix NULL parent dereference in fork event processing Date: Sat, 12 Sep 2026 08:56:59 +0200 Message-ID: <20260912065629.420129134@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnaldo Carvalho de Melo [ Upstream commit 73ac546bd6ba8ed4dc8d7a90fcb9bb8236de1568 ] machine__process_fork_event() calls machine__findnew_thread() for the parent thread, which can return NULL on allocation failure. The code then dereferences parent via thread__pid(parent) without a NULL check when validating whether the parent PID matches. The later NULL check at thread__fork() does not prevent this earlier dereference. Add a NULL guard before accessing the parent thread. Fixes: 5cb73340d92a ("perf tools: Make fork event processing more resilient") Reported-by: sashiko-bot Cc: Adrian Hunter Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim Signed-off-by: Sasha Levin --- tools/perf/util/machine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index e2a6facd1c4e2..7da4de13951c9 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -2103,7 +2103,8 @@ int machine__process_fork_event(struct machine *machine, union perf_event *event * (fork) event that would have removed the thread was lost. Assume the * latter case and continue on as best we can. */ - if (thread__pid(parent) != (pid_t)event->fork.ppid) { + if (parent != NULL && + thread__pid(parent) != (pid_t)event->fork.ppid) { dump_printf("removing erroneous parent thread %d/%d\n", thread__pid(parent), thread__tid(parent)); machine__remove_thread(machine, parent); -- 2.53.0