From: Narek Jilavyan <njilav@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Mateusz Guzik <mjguzik@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] fs: do not cache a symlink length that disagrees with the string
Date: Wed, 19 Aug 2026 13:03:17 +0000 [thread overview]
Message-ID: <20260819130317.2864113-1-njilav@gmail.com> (raw)
In-Reply-To: <ymvbwy6meo6wkp7fmkcuimqk3k6idaurijrrzpd6uqcbxirkkb@2dpz7trwewc6>
On Tue 18-08-26 23:35:53, Jan Kara wrote:
> I don't know but to me this looks like overly defensive programming... If
> we call strlen() in inode_set_cached_link(), then why pass the length to it
> as an argument in the first place?
You're right, and so was Mateusz. Please drop this one.
Going back over the callers: erofs and ext4 both run strlen()/strnlen()
themselves and reject the inode as corrupted before they ever call the
helper, and shmem and ext4's create path pass a length derived from the
string they just wrote. Every caller already guarantees the contract, and
the two that take the length from untrusted on-disk metadata verify it
independently of this helper.
I cited those same two callers in the commit message as evidence that the
API was fragile. That was backwards - they are evidence that it works as
documented. What actually remained was "a future caller might get it
wrong", which does not justify a strlen() on every symlink setup, and, as
you point out, leaves the length parameter with no purpose.
Sorry for the noise.
Thanks,
Narek
next prev parent reply other threads:[~2026-08-19 13:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 8:17 [PATCH] fs: do not cache a symlink length that disagrees with the string Narek Jilavyan
2026-08-17 15:24 ` Mateusz Guzik
2026-08-18 21:35 ` Jan Kara
2026-08-19 13:03 ` Narek Jilavyan [this message]
2026-08-17 16:17 ` [PATCH v2] " Narek Jilavyan
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=20260819130317.2864113-1-njilav@gmail.com \
--to=njilav@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--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.