[PATCH v2] ovl: Filter invalid inodes with missing lookup function

Vasiliy Kovalev posted 1 patch 1 year, 2 months ago
fs/overlayfs/util.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH v2] ovl: Filter invalid inodes with missing lookup function
Posted by Vasiliy Kovalev 1 year, 2 months ago
Add a check to the ovl_dentry_weird() function to prevent the
processing of directory inodes that lack the lookup function.
This is important because such inodes can cause errors in overlayfs
when passed to the lowerstack.

Reported-by: syzbot+a8c9d476508bd14a90e5@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=a8c9d476508bd14a90e5
Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
Cc: <stable@vger.kernel.org>
---
 fs/overlayfs/util.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 3bb107471fb42..9aa7493b1e103 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -202,6 +202,9 @@ void ovl_dentry_init_flags(struct dentry *dentry, struct dentry *upperdentry,
 
 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 |
 				  DCACHE_MANAGE_TRANSIT |
 				  DCACHE_OP_HASH |
-- 
2.33.8
Re: [PATCH v2] ovl: Filter invalid inodes with missing lookup function
Posted by Amir Goldstein 1 year, 2 months ago
On Tue, Nov 19, 2024 at 4:58 PM Vasiliy Kovalev <kovalev@altlinux.org> wrote:
>
> Add a check to the ovl_dentry_weird() function to prevent the
> processing of directory inodes that lack the lookup function.
> This is important because such inodes can cause errors in overlayfs
> when passed to the lowerstack.
>
> Reported-by: syzbot+a8c9d476508bd14a90e5@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?extid=a8c9d476508bd14a90e5
> Suggested-by: Miklos Szeredi <miklos@szeredi.hu>
> Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
> Cc: <stable@vger.kernel.org>
> ---
>  fs/overlayfs/util.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
> index 3bb107471fb42..9aa7493b1e103 100644
> --- a/fs/overlayfs/util.c
> +++ b/fs/overlayfs/util.c
> @@ -202,6 +202,9 @@ void ovl_dentry_init_flags(struct dentry *dentry, struct dentry *upperdentry,
>
>  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 |
>                                   DCACHE_MANAGE_TRANSIT |
>                                   DCACHE_OP_HASH |
> --
> 2.33.8
>

Applied to overlayfs-next. Will send along with 6.13 PR

Thanks,
Amir.