* FAILED: patch "[PATCH] ovl: check that the parents of volatile/dirty are dirs" failed to apply to 5.10-stable tree
@ 2026-11-04 14:35 gregkh
2026-11-05 16:23 ` [PATCH 5.10.y] ovl: check that the parents of volatile/dirty are dirs Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2026-11-04 14:35 UTC (permalink / raw)
To: mason, amir73il, josef; +Cc: stable
The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x e34d2ef818e4c7676d8d8e1bf43e6a1ed39efb2a
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026110454-overstate-universe-e323@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From e34d2ef818e4c7676d8d8e1bf43e6a1ed39efb2a Mon Sep 17 00:00:00 2001
From: Chris Mason <mason@kernel.org>
Date: Wed, 7 Oct 2026 10:15:11 +0000
Subject: [PATCH] ovl: check that the parents of volatile/dirty are dirs
An unprivileged user crashes the kernel by mounting overlayfs with the
volatile option.
A dentry that serves as the parent of a lookup must be a directory.
ovl_create_volatile_dirty() walks work/incompat/volatile/dirty by name,
and ovl_lookup_or_create() returns an existing entry whatever its type.
A file or a symlink that another task creates during the mount becomes
the parent of the next lookup, which calls a NULL ->lookup.
An unprivileged user mounted overlayfs with "volatile" in a user
namespace while a second process created a symlink named work/incompat,
and the mount task oopsed on a NULL ->lookup call.
Fix this by returning -ENOTDIR from ovl_lookup_or_create() when the
caller asked for a directory and the existing entry is a non-dir.
Fixes: c86243b090bc ("ovl: provide a mount option "volatile"")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index bd0a3f9039d2..18f56d463572 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -621,16 +621,21 @@ cleanup_temp:
static struct dentry *ovl_lookup_or_create(struct ovl_fs *ofs,
struct dentry *parent,
- const char *name, umode_t mode)
+ const char *name, bool is_dir)
{
struct dentry *child;
child = ovl_start_creating_upper(ofs, parent, &QSTR(name));
if (!IS_ERR(child)) {
- if (!child->d_inode)
+ if (!child->d_inode) {
child = ovl_create_real(ofs, parent, child,
&QSTR(name),
- OVL_CATTR(mode));
+ OVL_CATTR(is_dir ? S_IFDIR :
+ S_IFREG));
+ } else if (is_dir && !d_can_lookup(child)) {
+ end_creating(child);
+ child = ERR_PTR(-ENOTDIR);
+ }
end_creating_keep(child);
}
dput(parent);
@@ -652,7 +657,7 @@ static int ovl_create_volatile_dirty(struct ovl_fs *ofs)
const char *const *name = volatile_path;
for (ctr = ARRAY_SIZE(volatile_path); ctr; ctr--, name++) {
- d = ovl_lookup_or_create(ofs, d, *name, ctr > 1 ? S_IFDIR : S_IFREG);
+ d = ovl_lookup_or_create(ofs, d, *name, ctr > 1);
if (IS_ERR(d))
return PTR_ERR(d);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 5.10.y] ovl: check that the parents of volatile/dirty are dirs
2026-11-04 14:35 FAILED: patch "[PATCH] ovl: check that the parents of volatile/dirty are dirs" failed to apply to 5.10-stable tree gregkh
@ 2026-11-05 16:23 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-11-05 16:23 UTC (permalink / raw)
To: stable; +Cc: Chris Mason, Josef Bacik, Amir Goldstein, Sasha Levin
From: Chris Mason <mason@kernel.org>
[ Upstream commit e34d2ef818e4c7676d8d8e1bf43e6a1ed39efb2a ]
An unprivileged user crashes the kernel by mounting overlayfs with the
volatile option.
A dentry that serves as the parent of a lookup must be a directory.
ovl_create_volatile_dirty() walks work/incompat/volatile/dirty by name,
and ovl_lookup_or_create() returns an existing entry whatever its type.
A file or a symlink that another task creates during the mount becomes
the parent of the next lookup, which calls a NULL ->lookup.
An unprivileged user mounted overlayfs with "volatile" in a user
namespace while a second process created a symlink named work/incompat,
and the mount task oopsed on a NULL ->lookup call.
Fix this by returning -ENOTDIR from ovl_lookup_or_create() when the
caller asked for a directory and the existing entry is a non-dir.
Fixes: c86243b090bc ("ovl: provide a mount option "volatile"")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
[ sashal: replaced end_creating(child) with dput(child) while retaining the existing explicit parent unlock ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/overlayfs/super.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 5d7df839902df..5b50a3c2289aa 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1242,16 +1242,23 @@ static int ovl_check_rename_whiteout(struct dentry *workdir)
}
static struct dentry *ovl_lookup_or_create(struct dentry *parent,
- const char *name, umode_t mode)
+ const char *name, bool is_dir)
{
size_t len = strlen(name);
struct dentry *child;
inode_lock_nested(parent->d_inode, I_MUTEX_PARENT);
child = lookup_one_len(name, parent, len);
- if (!IS_ERR(child) && !child->d_inode)
- child = ovl_create_real(parent->d_inode, child,
- OVL_CATTR(mode));
+ if (!IS_ERR(child)) {
+ if (!child->d_inode) {
+ child = ovl_create_real(parent->d_inode, child,
+ OVL_CATTR(is_dir ? S_IFDIR :
+ S_IFREG));
+ } else if (is_dir && !d_can_lookup(child)) {
+ dput(child);
+ child = ERR_PTR(-ENOTDIR);
+ }
+ }
inode_unlock(parent->d_inode);
dput(parent);
@@ -1272,7 +1279,7 @@ static int ovl_create_volatile_dirty(struct ovl_fs *ofs)
const char *const *name = volatile_path;
for (ctr = ARRAY_SIZE(volatile_path); ctr; ctr--, name++) {
- d = ovl_lookup_or_create(d, *name, ctr > 1 ? S_IFDIR : S_IFREG);
+ d = ovl_lookup_or_create(d, *name, ctr > 1);
if (IS_ERR(d))
return PTR_ERR(d);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-05 16:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 14:35 FAILED: patch "[PATCH] ovl: check that the parents of volatile/dirty are dirs" failed to apply to 5.10-stable tree gregkh
2026-11-05 16:23 ` [PATCH 5.10.y] ovl: check that the parents of volatile/dirty are dirs Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox