From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: kernel test robot <oliver.sang@intel.com>,
oe-lkp@lists.linux.dev, lkp@intel.com,
linux-kernel@vger.kernel.org,
Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Christian Brauner <brauner@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Ajay Kaher <ajay.kaher@broadcom.com>,
linux-trace-kernel@vger.kernel.org
Subject: Re: [linus:master] [eventfs] 852e46e239: BUG:unable_to_handle_page_fault_for_address
Date: Mon, 29 Jan 2024 15:26:00 -0500 [thread overview]
Message-ID: <20240129152600.7587d1aa@gandalf.local.home> (raw)
In-Reply-To: <CAHk-=wgp7UkG31=cCcbSdhMv6-vBJ=orktUOUdiLzw4tQ4gDLg@mail.gmail.com>
On Mon, 29 Jan 2024 11:51:52 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:
> On Mon, 29 Jan 2024 at 11:24, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > So the patch was completely broken. Here's the one that should
> > actually compile (although still not actually *tested*).
>
> Note that this fixes the d_instantiate() ordering wrt initializing the inode.
>
> But as I look up the call chain, I see many more fundamental mistakes.
>
> Steven - the reason you think that the VFS doesn't have documentation
> is that we *do* have tons of documentation, but it's of the kind "Here
> is what you should do".
>
> It is *not* of the kind that says "You messed up and did something
> else, and how do you recover from it?".
When I first worked on this, I did read all the VFS documentation, and it
was difficult to understand what I needed and what I didn't. It is focused
on a real file system and not a pseudo ones. Another mistake I made was
thinking that debugfs was doing things the "right" way as well. And having
a good idea of how debugfs worked, and thinking it was correct, just made
reading VFS documentation even more difficult as I couldn't relate what I
knew (about debugfs) with what was being explained. I thought it was
perfectly fine to use dentry as a handle for the file system. I did until
you told me it wasn't. That made a profound change in my understanding of
how things are supposed to work.
>
> So the fundamental bug I now find is that eventfs_root_lookup() gets a
> target dentry, and for some unfathomable reason it then does
>
> ret = simple_lookup(dir, dentry, flags);
>
> on it. Which is *completely* broken, because what "simple_lookup()"
> does is just say "oh, you didn't have a dentry of this kind before, so
> clearly a lookup must be a non-existent file". Remember: this is for
> 'tmpfs' kinds of filesystems where the dentry cache cotnains *ALL*
> files.
Sorry, I don't really understand what you mean by "ALL files"? You mean
that all files in the pseudo file system has a dentry to it (like debugfs,
and the rest of tracefs)?
>
> For the tracefs kind of filesystem, it's TOTALLY BOGUS. What the
> "simple_lookup()" will do is just a plain
>
> d_add(dentry, NULL);
>
> and nothing else. And guess what *that* does? It basically
> instantiates a negative dentry, telling all other lookups that the
> path does not exist.
>
> So if you have two concurrent lookups, one will do that
> simple_lookup(), and the other will then - depending on timing -
> either see the negative dentry and return -ENOENT, or - if it comes in
> a bit later - see the new inode that then later gets added by the
> first lookup with d_instantiate().
>
> See? That simple_lookup() is not just unnecessary, but it's also
> actively completely WRONG. Because it instantiates a NULL pointer,
> other processes that race with the lookup may now end up saying "that
> file doesn't exist", even though it should.
>
> Basically, you can't use *any* of the "simple" filesystem helpers.
> Because they are all designed for that "the dentry tree is all there
> is" case.
Yeah, the above code did come about with me not fully understanding the
above. It's not that it wasn't documented, but I admit, when I read the VFS
documentation, I had a lot of trouble trying to make sense of things like
negative dentries and how they relate.
I now have a much better understanding of most of this, thanks to our
discussion here, and also knowing that using dentry as the main handle to a
file is *not* how to do it. When thinking it was, it made things much more
difficult to comprehend.
-- Steve
next prev parent reply other threads:[~2024-01-29 20:25 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-29 2:58 [linus:master] [eventfs] 852e46e239: BUG:unable_to_handle_page_fault_for_address kernel test robot
2024-01-29 4:36 ` Linus Torvalds
2024-01-29 17:01 ` Steven Rostedt
2024-01-29 17:40 ` Linus Torvalds
2024-01-29 17:44 ` Steven Rostedt
2024-01-29 17:45 ` Steven Rostedt
2024-01-29 17:56 ` Linus Torvalds
2024-01-29 17:55 ` Linus Torvalds
2024-01-29 19:24 ` Linus Torvalds
2024-01-29 19:51 ` Linus Torvalds
2024-01-29 20:26 ` Steven Rostedt [this message]
2024-01-29 20:51 ` Linus Torvalds
2024-01-29 21:45 ` Steven Rostedt
2024-01-29 22:19 ` Linus Torvalds
2024-01-29 21:55 ` Steven Rostedt
2024-01-29 22:22 ` Steven Rostedt
2024-01-29 22:35 ` Linus Torvalds
2024-01-29 22:42 ` Linus Torvalds
2024-01-29 22:49 ` Steven Rostedt
2024-01-30 0:01 ` Linus Torvalds
2024-01-30 0:35 ` Steven Rostedt
2024-01-30 1:50 ` Linus Torvalds
2024-01-30 3:56 ` Linus Torvalds
2024-01-30 8:43 ` Linus Torvalds
2024-01-30 9:12 ` Linus Torvalds
2024-01-30 14:39 ` Steven Rostedt
2024-01-30 16:49 ` Steven Rostedt
2024-01-30 16:55 ` Linus Torvalds
2024-01-30 17:06 ` Steven Rostedt
2024-01-30 17:09 ` Linus Torvalds
2024-01-30 16:51 ` Linus Torvalds
2024-01-30 18:23 ` Steven Rostedt
2024-01-30 19:19 ` Linus Torvalds
2024-01-30 19:37 ` Steven Rostedt
2024-01-30 19:54 ` Linus Torvalds
2024-01-30 20:04 ` Steven Rostedt
2024-01-31 15:58 ` Steven Rostedt
2024-01-31 16:13 ` Steven Rostedt
2024-01-31 17:28 ` Steven Rostedt
2024-01-31 17:26 ` Steven Rostedt
2024-01-31 19:35 ` Linus Torvalds
2024-01-31 19:42 ` Steven Rostedt
2024-01-30 18:36 ` Steven Rostedt
2024-01-29 22:47 ` Steven Rostedt
2024-01-29 23:15 ` Steven Rostedt
2024-01-30 2:08 ` Al Viro
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=20240129152600.7587d1aa@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=ajay.kaher@broadcom.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=oe-lkp@lists.linux.dev \
--cc=oliver.sang@intel.com \
--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;
as well as URLs for NNTP newsgroup(s).