From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) (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 C8518275871; Thu, 2 Oct 2025 17:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759427295; cv=none; b=r0k2fDcsIuF76cJIPJVbJ4bw+y0VKftTn2nwYU1Qt6gLK6R35t4iHLoN92V2Zxwoj7X51yIzFRFjLC8Xl0o9sjtZpVh4W3ZqLkg3wf8V7aGW4NeHxo+u7dd5EpXK3GlIoV3VTKV+PcS2AGcR8EgPlBk8+h3HFKQH4b5uMvM+BSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759427295; c=relaxed/simple; bh=XYgkd0+DGE/1FnzbQ4I2St1AM04FRrwrjLEauk7EzuU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jfIZC+hiEI01ILoa0d+A/kXM2tcitYZC7UUl29+41L7raicldY74U9/GBD1QEpF3wBLI7iTdKS400R7MrLMbG39B0mYXfq9KvuoE6oYb85GhsgY8rs/xCSj/8aekajWBMbq4UXTVHE82ylPW7hJ6tcte8YfhOt84IveHBBkA+EM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AB2391405F1; Thu, 2 Oct 2025 17:48:03 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf18.hostedemail.com (Postfix) with ESMTPA id ACED931; Thu, 2 Oct 2025 17:47:58 +0000 (UTC) Date: Thu, 2 Oct 2025 13:49:38 -0400 From: Steven Rostedt To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, x86@kernel.org, Masami Hiramatsu , Mathieu Desnoyers , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Arnaldo Carvalho de Melo , Namhyung Kim , Thomas Gleixner , Andrii Nakryiko , Indu Bhagat , "Jose E. Marchesi" , Beau Belgrave , Jens Remus , Linus Torvalds , Andrew Morton , Florian Weimer , Sam James , Kees Cook , "Carlos O'Donell" Subject: Re: [PATCH v16 4/4] perf tools: Merge deferred user callchains Message-ID: <20251002134938.756db4ef@gandalf.local.home> In-Reply-To: <20250908175430.639412649@kernel.org> References: <20250908175319.841517121@kernel.org> <20250908175430.639412649@kernel.org> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: ACED931 X-Stat-Signature: z1zkzqwnfe84x44krw87w6m5sbr49not X-Rspamd-Server: rspamout02 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1/DZhKLmvlmWd6s8dZVSpnODiEgOF2qdvw= X-HE-Tag: 1759427278-206294 X-HE-Meta: U2FsdGVkX18hSIjyIQqePbOlcJFCULJUyjEgT0deUyPFlISQraHRZy+ShMrtZqIdaVNT4Bk1Uic4K+HcViUHvJ88gH7EatLrOEFtXAY3ZQuYGO18bXoht3qrTPWD2VE1MAOEIoh78Zp714tT1psTxXDOiWpbP/HReT5mRE0Tvq8+IhNHkpWvAfY0puITRPN1YGjz3o6RMW7kYyeN6lIdKxd3mMjCCl1i930ipZu1KF3cS/0KbhZ4tl6nV07UvTcuVanrS8BzOmuZ/CP0wjuNvE3pjaOv2FLkYnrA/CiTBWy5NiE9+VxHMAC/NCGoZ4zHlsVlcDwf09MCjuCALcRfh0uKLiXRMNlb On Mon, 08 Sep 2025 13:53:23 -0400 Steven Rostedt wrote: > +static int evlist__deliver_deferred_samples(struct evlist *evlist, > + const struct perf_tool *tool, > + union perf_event *event, > + struct perf_sample *sample, > + struct machine *machine) > +{ > + struct deferred_event *de, *tmp; > + struct evsel *evsel; > + int ret = 0; > + > + if (!tool->merge_deferred_callchains) { > + evsel = evlist__id2evsel(evlist, sample->id); > + return tool->callchain_deferred(tool, event, sample, > + evsel, machine); > + } > + > + list_for_each_entry_safe(de, tmp, &evlist->deferred_samples, list) { > + struct perf_sample orig_sample; orig_sample is not initialized and can then contain junk. > + > + ret = evlist__parse_sample(evlist, de->event, &orig_sample); > + if (ret < 0) { > + pr_err("failed to parse original sample\n"); > + break; > + } > + > + if (sample->tid != orig_sample.tid) > + continue; > + > + if (event->callchain_deferred.cookie == orig_sample.deferred_cookie) > + sample__merge_deferred_callchain(&orig_sample, sample); The sample__merge_deferred_callchain() initializes both orig_sample.deferred_callchain and the callchain. But now that it's not being called, it can cause the below free to happen with junk as the callchain. This needs: else orig_sample.deferred_callchain = false; > + > + evsel = evlist__id2evsel(evlist, orig_sample.id); > + ret = evlist__deliver_sample(evlist, tool, de->event, > + &orig_sample, evsel,> machine); + > + if (orig_sample.deferred_callchain) > + free(orig_sample.callchain); > + > + list_del(&de->list); > + free(de); > + > + if (ret) > + break; > + } > + return ret; > +} -- Steve