linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Christian Brauner <brauner@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Andrew Lutomirski <luto@kernel.org>, Peter Anvin <hpa@zytor.com>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	Jan Kara <jack@suse.cz>
Subject: Re: [PATCH] vfs: relax linkat() AT_EMPTY_PATH - aka flink() - requirements
Date: Fri, 12 Apr 2024 10:43:06 -0700	[thread overview]
Message-ID: <CAHk-=wiYnnv7Kw7v+Cp2xU6_Fd-qxQMZuuxZ61LgA2=Gtftw-A@mail.gmail.com> (raw)
In-Reply-To: <20240412-vegetarisch-installieren-1152433bd1a7@brauner>

Side note: I'd really like to relax another unrelated AT_EMPTY_PATH
issue: we should just allow a NULL path for that case.

The requirement that you pass an actual empty string is insane. It's
wrong. And it adds a noticeable amount of expense to this path,
because just getting the single byte and looking it up is fairly
expensive.

This was more noticeable because glibc at one point (still?) did

        newfstatat(6, "", buf, AT_EMPTY_PATH)

when it should have just done a simple "fstat()".

So there were (are?) a *LOT* of AT_EMPTY_PATH users, and they all do a
pointless "let's copy a string from user space".

And yes, I know exactly why AT_EMPTY_PATH exists: because POSIX
traditionally says that a path of "" has to return -ENOENT, not the
current working directory. So AT_EMPTY_PATH basically says "allow the
empty path for lookup".

But while it *allows* the empty path, it does't *force* it, so it
doesn't mean "avoid the lookup", and we really end up doing a lot of
extra work just for this case. Just the user string copy is a big deal
because of the whole overhead of accessing user space, but it's also
the whole "allocate memory for the path etc".

If we either said "a NULL path with AT_EMPTY_PATH means empty", or
even just added a new AT_NULL_PATH thing that means "path has to be
NULL, and it means the same as AT_EMPTY_PATH with an empty path", we'd
be able to avoid quite a bit of pointless work.

                  Linus

  reply	other threads:[~2024-04-12 17:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  0:10 [PATCH] vfs: relax linkat() AT_EMPTY_PATH - aka flink() - requirements Linus Torvalds
2024-04-11  0:20 ` Linus Torvalds
2024-04-11  2:39 ` Linus Torvalds
2024-04-11  9:04   ` Christian Brauner
2024-04-11 12:25     ` Christian Brauner
2024-04-11 16:21       ` Linus Torvalds
2024-04-12  8:56         ` Christian Brauner
2024-04-11 16:15     ` Linus Torvalds
2024-04-11 16:44       ` Charles Mirabile
2024-04-11 17:29         ` Charles Mirabile
2024-04-11 17:35           ` Charles Mirabile
2024-04-11 18:13             ` Linus Torvalds
2024-04-11 19:34               ` Linus Torvalds
2024-04-12  7:45                 ` Christian Brauner
2024-04-12 15:36                   ` Linus Torvalds
2024-04-11 20:08               ` Charles Mirabile
2024-04-11 20:22                 ` Linus Torvalds
2024-04-12  6:44               ` Christian Brauner
2024-04-12  6:41         ` Christian Brauner
2024-04-12  9:07 ` Christian Brauner
2024-04-12 17:43   ` Linus Torvalds [this message]
2024-04-13  9:41     ` Christian Brauner
2024-04-13 15:16       ` Christian Brauner
2024-04-13 17:07         ` Linus Torvalds
2024-04-12 19:22   ` [PATCH] " Charles Mirabile

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='CAHk-=wiYnnv7Kw7v+Cp2xU6_Fd-qxQMZuuxZ61LgA2=Gtftw-A@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=hpa@zytor.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.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).