From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Kees Cook <keescook@chromium.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Ajay Kaher <ajay.kaher@broadcom.com>
Subject: Re: [for-linus][PATCH 1/3] eventfs: Have the inodes all for files and directories all be the same
Date: Mon, 22 Jan 2024 12:14:36 -0500 [thread overview]
Message-ID: <ccc4234d-8a47-4c0f-808a-95e61c9c9171@efficios.com> (raw)
In-Reply-To: <20240122100630.6a400dd3@gandalf.local.home>
On 2024-01-22 10:06, Steven Rostedt wrote:
> On Mon, 22 Jan 2024 11:38:52 +0100
> Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
[...]
>>
>> On Wed, Jan 17, 2024 at 3:37 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>>> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>>>
>>> The dentries and inodes are created in the readdir for the sole purpose of
>>> getting a consistent inode number. Linus stated that is unnecessary, and
>>> that all inodes can have the same inode number. For a virtual file system
>>> they are pretty meaningless.
>>>
>>> Instead use a single unique inode number for all files and one for all
>>> directories.
>>>
>>> Link: https://lore.kernel.org/all/20240116133753.2808d45e@gandalf.local.home/
>
> Yeah, Linus wanted me to try this first and see if there's any regressions.
> Well, I guess you just answered that.
>
>> This confuses "find".
>> Running "find /sys/" now prints lots of error messages to stderr:
>>
>> find: File system loop detected;
>> ‘/sys/kernel/debug/tracing/events/initcall/initcall_finish’ is part of
>> the same file system loop as
>> ‘/sys/kernel/debug/tracing/events/initcall’.
>
> So at a minimum, the directories need to have unique inode numbers.
[...]
> I'm using the eventfs_inode pointer to create a unique value for the inode.
> But it's being salted, hashed and then truncated. As it is very easy to
> read inodes (although by default, only root has access to read these
> inodes), the inode numbers themselves shouldn't be able to leak kernel
> addresses via the results of these inode numbers, would it?
Why use an improvised hashing function (re-purposed from
scripts/kconfig/symbol.c to a use-case which is exposed through a
userspace ABI prone to kernel address leaks) rather than simply
reserving values by setting bits in a bitmap ?
How many inodes do we realistically expect to have there ?
On my 6.1.0 kernel:
find /sys/kernel/tracing | wc -l
15598
(mainly due to TRACE_EVENT ABI files)
Hashing risks:
- Exposing kernel addresses if the hashing algorithm is broken,
- Collisions if users are unlucky (which could trigger those
'find' errors).
Those 15598 inode values fit within a single page (bitmap of
1922 bytes).
So I would recommend simply adding a bitmap per tracefs filesystem
instance to keep track of inode number allocation.
Creation/removal of files/directories in tracefs should not be
a fast-path anyway, so who cares about the speed of a find first
bit within a single page ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2024-01-22 17:14 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 14:35 [for-linus][PATCH 0/3] eventfs: A few more fixes for 6.8 Steven Rostedt
2024-01-17 14:35 ` [for-linus][PATCH 1/3] eventfs: Have the inodes all for files and directories all be the same Steven Rostedt
2024-01-22 10:38 ` Geert Uytterhoeven
2024-01-22 15:06 ` Steven Rostedt
2024-01-22 16:23 ` Geert Uytterhoeven
2024-01-22 16:47 ` Steven Rostedt
2024-01-22 17:37 ` Linus Torvalds
2024-01-22 17:39 ` Linus Torvalds
2024-01-22 18:19 ` Linus Torvalds
2024-01-22 18:27 ` Mathieu Desnoyers
2024-01-22 19:37 ` Steven Rostedt
2024-01-22 18:50 ` Kees Cook
2024-01-22 19:44 ` Steven Rostedt
2024-01-22 19:48 ` Steven Rostedt
2024-01-22 21:33 ` Kees Cook
2024-01-25 17:40 ` Christian Brauner
2024-01-25 18:07 ` Steven Rostedt
2024-01-25 18:08 ` Steven Rostedt
2024-01-26 8:07 ` Geert Uytterhoeven
2024-01-26 10:11 ` Christian Brauner
2024-01-26 16:25 ` Steven Rostedt
2024-01-26 19:09 ` Linus Torvalds
2024-01-26 13:16 ` Steven Rostedt
2024-01-26 14:06 ` Steven Rostedt
2024-01-22 17:14 ` Mathieu Desnoyers [this message]
2024-01-22 17:50 ` Steven Rostedt
2024-01-22 18:35 ` Mathieu Desnoyers
2024-01-22 19:59 ` Steven Rostedt
2024-01-17 14:35 ` [for-linus][PATCH 2/3] eventfs: Do not create dentries nor inodes in iterate_shared Steven Rostedt
2024-01-17 14:35 ` [for-linus][PATCH 3/3] eventfs: Use kcalloc() instead of kzalloc() Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ccc4234d-8a47-4c0f-808a-95e61c9c9171@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=ajay.kaher@broadcom.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=geert@linux-m68k.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®