From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=216.40.44.17 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796157473; b=J69/W64t+bdd7JcO4l4hgLYB+JcrPKrzZuv5IJy6ovQI7ML07uTog9ouyQGBSgb+ktjP gwraVP56gtEBE8C/Q5V9jPS2kq87yn9FZwhDUvQly+uFJD15c9GsHxQONRoBpX8y+nOyw 16uOZsO+OCIEDwBVNxlHJ9qkNw4pLkPZApaG0U7syITg7974SWmUnW1BKli84L9O7TFIn EBCWuR5PTe6g7n4MU3HN1Mw8hfqMtAqVWokKAtyKJRkBbc6dX70LxgZ+Q2hIebMRJ2Kpu XYX+da9QPfsBxDPPFlUVIwfP3U666lEw1MdT3BFAN6oRsXFw0ETprDeBWN9LEoPfQEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796157473; h=DMARC-Filter:Received:Received:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding:X-Rspamd-Queue-Id:X-Stat-Signature: X-Spam-Status:X-Rspamd-Server:X-Session-Marker:X-Session-ID: DKIM-Signature:X-HE-Tag:X-HE-Meta; bh=p3vaVfbGI2W+Rcd1UOsRsI+EVHQhLzubJXzTNvZlxxs=; b=fiTTIvGWWY4ScGoQMyMkl7Kc/9OTzZqKG3OZuWkyNg1m3PE2w2sDNBGrswLQSL+FNXsw 4ttN+nA9rnPOM5WEUszRGnlBYudMxE6nFs0VfDjAd6rJCKveNVmtQNNaidCTPLpoVJdP4 9G2ooaPuAddMKiKSGBvQjfGROipB7z68++JqJhNhuhLMIBwyN+LyC5ArMwPGZqXw5M7jr V28tzldzlqQUSqb1nNyPYFYatv6ZT6KvSf6h+WB1MZTOYnE6rYRRqFLyN16cOKk4tQSO2 PLw28tsXgq5zaXLGNp/5I9OmaRG0xjMQ4jOmWC2wl+jHSjBiXxG/TEEuHiyIXbOujzQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; dkim=pass header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b=jpuZ0MTu; arc=none smtp.remote-ip=216.40.44.17 Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7020F606A320 for ; Tue, 1 Dec 2026 20:37:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7020F606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b=jpuZ0MTu Received: from omf16.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 57DFEA802F; Tue, 1 Dec 2026 20:37:51 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf16.hostedemail.com (Postfix) with ESMTPA id 981642000E; Tue, 1 Dec 2026 20:37:49 +0000 (UTC) Date: Tue, 1 Dec 2026 15:37:48 -0500 From: Steven Rostedt To: sashiko-bot@kernel.org Cc: sashiko-reviews@lists.linux.dev, "Linux Trace Kernel" Subject: Re: [PATCH] tracing: Free all event filters after RCU synchronization Message-ID: <20261201153748.4f6ba182@gandalf.local.home> In-Reply-To: References: <20261201151540.797d15a0@gandalf.local.home> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 981642000E X-Stat-Signature: 89cihd9eakn96a3gahh75j4pwy41p9nr X-Rspamd-Server: rspamout02 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1/O/N1yh/Oi0vcGPeV38FcyOjT+I2YcLek= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=goodmis.org; h=date:from:to:cc:subject:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=dkim1; bh=p3vaVfbGI2W+Rcd1UOsRsI+EVHQhLzubJXzTNvZlxxs=; b=jpuZ0MTu+FMJM0G2DNePycYOcUsBvjjQcDt5gH9Ne1Hq2lh2NlRfnyt/pm9MvScSRHyDlZpNpTOHD4cQLY6JR254XVWiKLVPOlb+8ekwwWVu37VaKoF2gABUV8QSAkczalZM76vkgjYTGnwt0sGU5EWgiG+i9NZVlhSMjKPdnDI= X-HE-Tag: 1796157469-471309 X-HE-Meta: U2FsdGVkX18LoLRelFQoOADmZE8bili0b5+jxmF4AAlsgOXsOz5mnATvKBH96l1/fXR4y2WYckV5e3kHoNRR++wSKZqLzzWlGBWRVRuaBAMDElq8o1HqDFF66LiRqkf1+Hh+/PMdAkbsLfK5FfDeE0wxe47HXxyP5su3VRSJU6D3ROakR4xEuaxO51xymefa81MJWVlScl7m7TG2dpwX7qsjV9/fpQqDq6nJxLAW1I8EActJgDRC8j1+xE3blUF4ACXppes86G417EqvxHj1dOrl1Ylr3v/ADzSuzB+3oAVIxFIV55U/UUUDllK1B6yPhr72dnwmsRjKSy/7KJ5OhtywWbNbpDP7 On Tue, 01 Dec 2026 20:23:29 +0000 sashiko-bot@kernel.org wrote: > [ ... ] > > @@ -1495,47 +1464,33 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir, > [ ... ] > > - list_for_each_entry(file, &tr->events, list) { > > - if (file->system != dir || !file->filter) > > - continue; > > - __free_subsystem_filter(file); > > + event_clear_filter(file); > > } > > - __free_filter(filter); > > + > > + delay_free_filter(filter_list); > > } > > [Severity: Low] > Removing the fallback path in filter_free_subsystem_filters() leaves > __free_subsystem_filter() unused. Should it be removed as well? Oh yes, thanks! > > > @@ -2377,9 +2332,9 @@ static int process_system_preds(struct trace_subsystem_dir *dir, > > char *filter_string) > > { > > struct trace_event_file *file; > > - struct filter_list *filter_item; > > struct event_filter *filter = NULL; > > - struct filter_head *filter_list; > > + struct event_filter *filter_list; > > + struct event_filter *efilter; > > bool fail = true; > > int ret = -ENOMEM; > > int err; > > @@ -2413,18 +2368,16 @@ static int process_system_preds(struct trace_subsystem_dir *dir, > > fail = false; > > } > > > > - filter_item = kzalloc_obj(*filter_item); > > - if (!filter_item) > > - goto fail_mem; > > - > > - list_add_tail(&filter_item->list, &filter_list->list); > > /* > > * Regardless of if this returned an error, we still > > * replace the filter for the call. > > */ > > - filter_item->filter = event_filter(file); > > + efilter = event_filter(file); > > event_set_filter(file, filter); > > filter = NULL; > > + > > + if (efilter) > > + list_add_tail(&efilter->list, &filter_list->list); > > } > > [Severity: High] > Does free_filter_list() pass uninitialized filter_list->prog and > filter_list->filter_string pointers to free_prog() and kfree()? > > process_system_preds() still allocates a dummy filter_list with > kmalloc_obj() and only initializes filter_list->list: Bah, I was thinking that kmalloc_obj() zeroed out the memory, but it's just a normal kmalloc. I need to switch that to a kzalloc_obj(). > > kernel/trace/trace_events_filter.c:process_system_preds() { > ... > filter_list = kmalloc_obj(*filter_list); > if (!filter_list) > return -ENOMEM; > > INIT_LIST_HEAD(&filter_list->list); > ... > } > > Because free_filter_list() now calls __free_filter(filter_list) on the > list head itself instead of kfree(filter_list), writing a subsystem filter > causes __free_filter() to dereference and free uninitialized heap memory > from filter_list->prog and filter_list->filter_string. > > Could process_system_preds() initialize filter_list to NULL and use the > first non-NULL efilter as the list head, matching > filter_free_subsystem_filters()? > Yes, and that's because I thought the temporary filter was zeroed out, but it wasn't. v2 on the way. -- Steve