From nobody Mon Sep 28 23:50:57 2026 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 EE35D49505F for ; Fri, 14 Aug 2026 18:26:35 +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=1786731997; cv=none; b=madWXKyUn7/kI0s6lsC/icxGVGB1urEdpzSaylQj3ow1rFpl0Mc2Yzt0v05zxopT+YiRAlPRnmxiXsShxKpu58IsEffi3SlcwhII2NTTKq3jvqbYKMxTYI7b9B5onTeNVHnbEgy9l+xntaZlTziEe6HSDfD9J2Bn2E5bzf+SkS0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786731997; c=relaxed/simple; bh=mydrn5/cs2rpyHWM3BEYePgDcRn2+lrny/8dmSL9bkQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Bj+7grmVzKkYU+ND18SjkZ7xlgFTYR5rkVEqrq4dWwHtda9otiy7gx0tJ1QiZfVkf1SWxz3FT3dzsBe3OQyVbrSxlK+P9JJ8mxD9eJaD64qvdqOr2BM+tQIylF63154+FK420rnYT3T9pDxfUuQ19tNPng0GPcM8n1PApGQzLcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ckrrj/Me; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ckrrj/Me" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAD3D1F000E9; Fri, 14 Aug 2026 18:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786731995; bh=6H0lVRt/Lz8NJqTC89DqVCwMoG4u7K7dtDUcdcELjCQ=; h=Date:From:To:Cc:Subject:References; b=ckrrj/MenSUv5ri7P+Be9oPZSw6mosV4Fr0gQ/i1uYN4BCwCqS/QpAjpZ7tcGaCIh q5m/74Cm0D3NP0mQ8+b4nGkGRtwfnnFHcFMze3C0fld9Bd4xvXN9N5XFlVtRepxaJm HhyDALuzNvd4D5U2yiwQdDowmhE/5C7prilDUzfWTztIsmMOJPmVSVzBxjJrjXtHAp Oa503ZR/pDSJeWpSXlke6TbJgzLVBQKyYGp8o+WVvDcKTOcg4dcQokEUqWuvaJU4iu Wdop+oY47FlYxEs2SSRl/a/1Mw+faeb6/Scuw2En4edRC6joZ3h5Ko4TQDcqZeQfOE aMGKKHy4CKIxQ== Received: from rostedt by gandalf with local (Exim 4.99.4) (envelope-from ) id 1wuwcI-000000046wl-2kcy; Fri, 14 Aug 2026 14:26:54 -0400 Message-ID: <20260814182654.512791362@kernel.org> User-Agent: quilt/0.69 Date: Fri, 14 Aug 2026 14:26:20 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Anubhav Shelat Subject: [for-next][PATCH 1/2] eventfs: Define event fields before directory creation References: <20260814182619.668645822@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Anubhav Shelat Move the event_define_fields() call in event_create_dir() before the eventfs directory creation. Previously, a failure after directory creation wouldn't clean up eventfs_inode because the error path didn't call eventfs_remove_dir(). This eliminates the need to clean up the eventfs directories if event_define_fields() fails. Link: https://patch.msgid.link/20260715135231.338535-3-ashelat@redhat.com Signed-off-by: Anubhav Shelat Signed-off-by: Steven Rostedt --- kernel/trace/trace_events.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index c01b10b99f67..ea608519f4b1 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -3192,6 +3192,13 @@ event_create_dir(struct eventfs_inode *parent, struc= t trace_event_file *file) if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) =3D=3D 0)) return -ENODEV; =20 + ret =3D event_define_fields(call); + if (ret < 0) { + pr_warn("Could not initialize trace point events/%s\n", + trace_event_name(call)); + return ret; + } + e_events =3D event_subsystem_dir(tr, call->class->system, file, parent); if (!e_events) return -ENOMEM; @@ -3210,12 +3217,6 @@ event_create_dir(struct eventfs_inode *parent, struc= t trace_event_file *file) =20 file->ei =3D ei; =20 - ret =3D event_define_fields(call); - if (ret < 0) { - pr_warn("Could not initialize trace point events/%s\n", name); - return ret; - } - /* Gets decremented on freeing of the "enable" file */ event_file_get(file); =20 --=20 2.53.0 From nobody Mon Sep 28 23:50:57 2026 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 EE2B1495058 for ; Fri, 14 Aug 2026 18:26:35 +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=1786731997; cv=none; b=ZflS0JU4CztpfhO0tvdGWsGQyBfZWoi1Y7+pEppjPQliLEoQDmv5kCHUil3/MVy+JxdFQbn/+EL8VmXiWtcoRGDdO5RGOnItjEvMaaGWBkaTzFo4Zwm2PCYa4I8QFaVgCN0Bp2aSmCyo9zqU3/Lz8UinRXFVoJ3w2mxYIutkvRQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786731997; c=relaxed/simple; bh=agnXVRUb68ayHHtdMf7FvSJfCjaOKYrbCHlUXVpXSKo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ovdDGvQ0xUrWbE+qJoRUFHAtVSL9cvOAsTY1ck4XcSJKxD43HLYu/0F82C7xKNRSqAmbbu0a6SY/rZZ8ZqEP9kTasuJTEUapTBplP30/fOJJiWrvnMcJ2pIs5Y540VF1l4wkIalvUCeOgGcGwjxA7+jtNa+VaFpwPqm7vVVajnY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E4uNPU4W; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E4uNPU4W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C71D21F00A3E; Fri, 14 Aug 2026 18:26:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786731995; bh=CNUTQpyH4zbv/RALVUiaf/aFuiAVQiJt4oztGb1fJK4=; h=Date:From:To:Cc:Subject:References; b=E4uNPU4WOlun/Hsiiu7rFo9uuhdtVusZ+x/BXXNbsU70cPYiACVUjxVYdFIc+VDmx 37IQATXYLWNQjUB4MJzbqFPwAByiJOHznAssEXg+6N1z7cuI20Na6x0fwssuDzmSf8 /B9930L0uTeK9ylZnrxVPrmocgz27qYBx7jLdur7FwGZjIolWFiuc27xjTnI42m3/A Us6XwgxposjT737r69vZO50up9Srh+vI628vvLqGI7ZwAnKczrYBWEF84i21rcofZM VCEn/L2GZWQoHQvBowdYKM7ggEyrP2O4UGJQyPjPcJlvxvV4w4kod4faAvTjAluwwV F36eK2Ru2ghJA== Received: from rostedt by gandalf with local (Exim 4.99.4) (envelope-from ) id 1wuwcI-000000046xF-3Rj0; Fri, 14 Aug 2026 14:26:54 -0400 Message-ID: <20260814182654.677012890@kernel.org> User-Agent: quilt/0.69 Date: Fri, 14 Aug 2026 14:26:21 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Anubhav Shelat Subject: [for-next][PATCH 2/2] eventfs: Add warning for out of bounds pos in __eventfs_iterate() References: <20260814182619.668645822@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt Sashiko has complained about out of bounds issues if ctx->pos isn't what is expected in __eventfs_iterate()[1]. This would be an issue if the logic that calls __eventfs_iterate() didn't already prevent the code from going out of bounds. The issue Sashiko brings up is if a user uses lseek64() to put in a position like 0x100000000 which will overflow the integer used to iterate the files. This should never be an issue because both tracefs and eventfs uses the default "maxbytes" for its superblock "s_maxbytes" field which is defined as: fs/super.c: s->s_maxbytes =3D MAX_NON_LFS; include/linux/fs.h:#define MAX_NON_LFS ((1UL<<31) - 1) Where MAX_NON_LFS turns into 0x7fffffff. Testing this with code to try to pass 0x100000000 to lseek64() to a eventfs directory returns -EINVAL. But relying on logic for the integrity of a function is not very robust. Add a WARN_ON_ONCE() in case the ctx->pos is out of the expected range. [1] https://sashiko.dev/#/patchset/20260810160708.3460a2fd%40gandalf.local.= home Link: https://patch.msgid.link/20260810175928.5f4d9d5c@gandalf.local.home Signed-off-by: Steven Rostedt --- fs/tracefs/event_inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 39c7a34531e8..96a561970fcc 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -584,6 +584,10 @@ static int eventfs_iterate(struct file *file, struct d= ir_context *ctx) if (!(ti->flags & TRACEFS_EVENT_INODE)) return -EINVAL; =20 + /* Logic should prevent ctx->pos from going out of range */ + if (WARN_ON_ONCE(ctx->pos < 2 || ctx->pos > 0x7fffffffULL)) + return -EINVAL; + c =3D ctx->pos - 2; =20 guard(srcu)(&eventfs_srcu); --=20 2.53.0