Skip to content

Commit

Permalink
ovl: don't allow datadir only
Browse files Browse the repository at this point in the history
commit eb3a04a upstream.

In theory overlayfs could support upper layer directly referring to a data
layer, but there's no current use case for this.

Originally, when data-only layers were introduced, this wasn't allowed,
only introduced by the "datadir+" feature, but without actually handling
this case, resulting in an Oops.

Fix by disallowing datadir without lowerdir.

Reported-by: Giuseppe Scrivano <gscrivan@redhat.com>
Fixes: 24e16e3 ("ovl: add support for appending lowerdirs one by one")
Cc: <stable@vger.kernel.org> # v6.7
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Alexander Larsson <alexl@redhat.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Miklos Szeredi authored and Greg Kroah-Hartman committed Apr 25, 2025
1 parent 0294580 commit b9e3579
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,11 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb,
return ERR_PTR(-EINVAL);
}

if (ctx->nr == ctx->nr_data) {
pr_err("at least one non-data lowerdir is required\n");
return ERR_PTR(-EINVAL);
}

err = -EINVAL;
for (i = 0; i < ctx->nr; i++) {
l = &ctx->lower[i];
Expand Down

0 comments on commit b9e3579

Please sign in to comment.