From: Vasiliy Kovalev <kovalev@altlinux.org>
To: Miklos Szeredi <miklos@szeredi.hu>, Amir Goldstein <amir73il@gmail.com>
Cc: Vasiliy Kovalev <kovalev@altlinux.org>,
linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ovl: Add check for missing lookup operation on inode
Date: Tue, 19 Nov 2024 17:33:03 +0300 [thread overview]
Message-ID: <6fb27fea-3998-0fdf-9210-d7479baf0570@basealt.ru> (raw)
In-Reply-To: <CAJfpegvx-oS9XGuwpJx=Xe28_jzWx5eRo1y900_ZzWY+=gGzUg@mail.gmail.com>
Hi,
19.11.2024 12:05, Miklos Szeredi wrote:
> On Mon, 18 Nov 2024 at 19:54, Amir Goldstein <amir73il@gmail.com> wrote:
>
>> Can you analyse what went wrong with the reproducer?
>> How did we get to a state where lowerstack of parent
>> has a dentry which is !d_can_lookup?
>
> Theoretically we could still get a an S_ISDIR inode, because
> ovl_get_inode() doesn't look at the is_dir value that lookup found.
> I.e. lookup thinks it found a non-dir, but iget will create a dir
> because of the backing inode's type.
>
> AFAICS this can only happen if i_op->lookup is not set on S_ISDIR for
> the backing inode, which shouldn't happen on normal filesystems.
> Reproducer seems to use bfs, which *should* be normal, and bfs_iget
> certainly doesn't do anything weird in that case, so I still don't
> understand what is happening.
During testing, it was discovered that BFS can return a directory inode
without a lookup operation. Adding the following check in bfs_iget:
struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
{
...
brelse(bh);
+ if (S_ISDIR(inode->i_mode) && !inode->i_op->lookup) {
+ printf("Directory inode missing lookup %s:%08lx\n",
inode->i_sb->s_id, ino);
+ goto error;
+ }
+
unlock_new_inode(inode);
return inode;
error:
iget_failed(inode);
return ERR_PTR(-EIO);
}
prevents the error but exposes an invalid inode:
loop0: detected capacity change from 0 to 64
BFS-fs: bfs_iget(): Directory inode missing lookup loop0:00000002
overlayfs: overlapping lowerdir path
Would this be considered a valid workaround, or does BFS require further
fixes?
> In any case something like the following should filter out such weirdness:
>
> bool ovl_dentry_weird(struct dentry *dentry)
> {
> + if (!d_can_lookup(dentry) && !d_is_file(dentry) &&
> !d_is_symlink(dentry))
> + return true;
> +
> return dentry->d_flags & (DCACHE_NEED_AUTOMOUNT |
I tested this addition successfully.
Additionally, fixes for BFS seem to be discussed reluctantly.
For instance, this patch set [1] has remained unanswered.
Perhaps it would be worth considering discarding invalid inodes at the
overlayfs level?
[1]
https://lore.kernel.org/all/20240822161219.459054-1-kovalev@altlinux.org/
> Thanks,
> Miklos
--
Thanks,
Vasiliy Kovalev
next prev parent reply other threads:[~2024-11-19 14:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 14:17 Vasiliy Kovalev
2024-11-18 18:54 ` Amir Goldstein
2024-11-19 9:05 ` Miklos Szeredi
2024-11-19 14:33 ` Vasiliy Kovalev [this message]
2024-11-19 15:11 ` Amir Goldstein
2024-11-19 15:58 ` [PATCH v2] ovl: Filter invalid inodes with missing lookup function Vasiliy Kovalev
2024-11-20 12:34 ` Amir Goldstein
2024-11-23 0:21 ` [PATCH] ovl: Add check for missing lookup operation on inode 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=6fb27fea-3998-0fdf-9210-d7479baf0570@basealt.ru \
--to=kovalev@altlinux.org \
--cc=amir73il@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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®