From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Eric Biggers <ebiggers@kernel.org>
Cc: tytso@mit.edu, linux-fsdevel@vger.kernel.org,
viro@zeniv.linux.org.uk, jaegeuk@kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v2] libfs: Attempt exact-match comparison first during casefold lookup
Date: Thu, 18 Jan 2024 12:42:27 -0300 [thread overview]
Message-ID: <8734uufy1o.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20240118035053.GB1103@sol.localdomain> (Eric Biggers's message of "Wed, 17 Jan 2024 19:50:53 -0800")
Eric Biggers <ebiggers@kernel.org> writes:
> On Wed, Jan 17, 2024 at 09:46:18PM -0300, Gabriel Krisman Bertazi wrote:
>> Note that, for strict mode, generic_ci_d_compare used to reject an
>> invalid UTF-8 string, which would now be considered valid if it
>> exact-matches the disk-name. But, if that is the case, the filesystem
>> is corrupt. More than that, it really doesn't matter in practice,
>> because the name-under-lookup will have already been rejected by
>> generic_ci_d_hash and we won't even get here.
>
> Can you make the code comment explain this, please?
will do, once we settle the other discussion about this point.
>
>> + /*
>> + * Attempt a case-sensitive match first. It is cheaper and
>> + * should cover most lookups, including all the sane
>> + * applications that expect a case-sensitive filesystem.
>> + */
>> + if (len == name->len && !memcmp(str, name->name, len))
>> + return 0;
>
> Is the memcmp() safe, considering that the 'str' can be concurrently
> modified?
You wrote quite a bit of the data race documentation, so you definitely
know better.
But I don't see how this could be a problem. the str pointer itself
can't change since it's already a copy of the dentry->d_name pointer; if
the string is external, it is guaranteed to exist until the end of the
lookup; Finally, If it's inlined, the string can change concurrently
which, in the worst case scenario, gives us a false result. But then,
VFS will retry, like we do for the case-insensitive comparison right
below.
..Right? :)
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2024-01-18 15:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-18 0:46 [PATCH v2] libfs: Attempt exact-match comparison first during casefold lookup Gabriel Krisman Bertazi
2024-01-18 3:50 ` Eric Biggers
2024-01-18 15:42 ` Gabriel Krisman Bertazi [this message]
2024-01-18 16:51 ` Gabriel Krisman Bertazi
2024-01-18 19:29 ` Linus Torvalds
2024-01-19 14:13 ` Gabriel Krisman Bertazi
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=8734uufy1o.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.