From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796403349; b=I+80GC9bl8nubNpFOpElhHoXRiC7zd8IgBgFUOGN1sCjSpwMkq6Su0k+/ehzvd4aQ92V 8xPA6HBSHiPmvauREgmRjM8n+BP0+ejqm//TpTYx4kJiGU4i7qZ3Q6BiOxxOFLRoRv2F9 VQTbfbc+Vj0PsPWkB5dKM+R2rGbaGO3e+0XTi7fnH2GNFSYGIDbXvO7zbji21wEm1jNGx h+v4MMAVEjaNtbx5J8m7cMTfhruUgy1QRY6C3sa32CTTfX46gP7AXDBs+B6CFKUM8wxnA prwpnnVTiDX/0sbwbo/R2UVISLxmvAtTu0HXpYGmeoD/BYh7yJwE/pn1YhHITlYsfuQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796403349; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=xkfI6BGu7p7GMY19EzSNknOhQh6zXlFtPMUpvnWSIgk=; b=oJs+xo/mMsaqzNKRlzeixZJjQjEeS51Fpfr2bP25ybdyTU07OXt2HK+bIJ5O41+FbB9m 9orf7sQOBeNOCtggBKJHUNB3Ni+v7po0+NgIkM5bEjO1p9oJ/dz8wAsmtL138xNLLtemX HYYXa+ZsjIBLo6bOX6Rywj3cPtZw9zKHCefem+RLcYg1uItHnZa+KE8/T08FDx9d2RkBr lm+jeqXYf/cKJgHJiNjKEICLHvv+EIFzzu6ubK7r+JaezF6Y4U4ki0RlyZqAD+MNgA6CV 35bnc//Wq36rhegqu9ibGAs64enUyUJW/ffYA5Rbpyz15TAvFT4YSG7qvOdlvITDnGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dYIz2djg; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E609606A322 for ; Fri, 4 Dec 2026 16:55:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dYIz2djg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 380CD1F000C2; Fri, 4 Dec 2026 16:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796403349; bh=xkfI6BGu7p7GMY19EzSNknOhQh6zXlFtPMUpvnWSIgk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dYIz2djg3G4nDraXcWb8vZW+/gCjQ8TvPhkg9rWG6jCKwz9lX7vTidt6Os/S98DPJ cRwffl3QfoLcjjJYAReGe71+HzrFGWlaPsb2tp4l8YxMgkr4EI/rDlvkCIZFoMFE2W 8Jur5llrBr4HFfqCApleAq5WyiDBAwejfi6EmPTz1sMThuej5KpR2Aqg0YmXuDR3r6 ZcEl+PtY5ADtPmh3VF7UWVQWYpZoLUg/eKwyzcbxUUQ2J0/giaS3cnKKPIKm2jB8AZ osON3uP03iooTd3Blsq0dLpY/yYGuqKbaUr6/4KNX+SYdUzK4wq/B2x3CXOjIHZBF/ CM0rIt5utHEGQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] tracing: Fix sanitize_field_type() overlapping strcpy() and word boundary check Reply-To: sashiko-reviews@lists.linux.dev To: EisenWalds Cc: linux-trace-kernel@vger.kernel.org In-Reply-To: <20261204163630.17660-2-aerovynqueque@gmail.com> References: <20261204163630.17660-1-aerovynqueque@gmail.com> <20261204163630.17660-2-aerovynqueque@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 16:55:48 +0000 X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] tracing: missing Fixes trailer for sanitize_field_type() bug fixes - [Low] tracing: redundant unsigned char cast and inaccurate UB comment for isalnum() -- commit fc0f6e4347c9a99f474f4909ae248ae5f2a89b9a Author: EisenWalds > tracing: Fix sanitize_field_type() overlapping strcpy() and word boundary= check > > sanitize_field_type() removes __attribute__((...)) from a type > string. It has two issues: > > 1. strcpy(attr, next) is called with overlapping source and > destination in the same buffer. Overlapping strcpy() is undefined > behavior per the C standard; use memmove() instead. > > 2. The word boundary check used isspace(attr[-1]), which skipped > attributes that follow punctuation such as "*__attribute__((...))" > or "(__attribute__((...))". Check for identifier characters > (alnum or '_') instead, so those forms are sanitized correctly. > > While here, compare against the buffer start (ret) instead of the > moving search position (next), so the previous-character check is > skipped only when attr is at the very beginning of the buffer. > Also cast to unsigned char before isalnum() to avoid undefined > behavior on signed char. > > Signed-off-by: EisenWalds [Severity: Low] This fixes two bugs in sanitize_field_type() introduced by commit 1a967e92bf47 ("tracing: Remove "__attribute__()" from the type field of event format"). Should this include: Fixes: 1a967e92bf47 ("tracing: Remove "__attribute__()" from the type fie= ld of event format") > diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c > index 0e396c67a704b..ec0194d164d57 100644 > --- a/kernel/trace/trace_events.c > +++ b/kernel/trace/trace_events.c > @@ -3703,8 +3703,19 @@ static char *sanitize_field_type(const char *type) > =20 > next =3D (char *)type; > while ((attr =3D strstr(next, ATTRIBUTE_STR))) { > - /* Retry if "__attribute__(" is a part of another word. */ > - if (attr !=3D next && !isspace(attr[-1])) { > + /* > + * Reject if "__attribute__(" is part of another identifier, > + * e.g. "my__attribute__(" or "_foo__attribute__(". > + * Checking the previous character is enough: alnum or '_' > + * means it is still part of an identifier. Other characters > + * (space, '*', '(', etc.) are valid because C allows an > + * attribute to follow punctuation, e.g. "*__attribute__((...))". > + * > + * Cast to unsigned char to avoid UB when char is signed and > + * the byte is non-ASCII. > + */ > + if (attr !=3D ret && > + (isalnum((unsigned char)attr[-1]) || attr[-1] =3D=3D '_')) { > next =3D attr + ATTRIBUTE_STR_LEN; > continue; > } [Severity: Low] This isn't a bug, but the (unsigned char) cast and the undefined behavior note in this comment and the commit message are unnecessary in the kernel. include/linux/ctype.h already casts the argument of isalnum() to unsigned char in __ismask(), and the top-level Makefile builds with -funsigned-char. Nearby callers such as update_event_printk() pass char directly to isalnum() without a cast. Can the cast and the undefined behavior note be dropped from the comment and commit message? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204163630.1766= 0-1-aerovynqueque@gmail.com?part=3D2