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 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-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 = 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 dir_context *ctx) if (!(ti->flags & TRACEFS_EVENT_INODE)) return -EINVAL; + /* Logic should prevent ctx->pos from going out of range */ + if (WARN_ON_ONCE(ctx->pos < 2 || ctx->pos > 0x7fffffffULL)) + return -EINVAL; + c = ctx->pos - 2; guard(srcu)(&eventfs_srcu); -- 2.53.0