* FAILED: patch "[PATCH] ovl: bump the impure dir version when linking a file with" failed to apply to 6.18-stable tree
@ 2026-11-25 10:44 gregkh
2026-11-26 2:03 ` [PATCH 6.18.y 1/6] cred: add prepare credential guard Sasha Levin
0 siblings, 1 reply; 7+ messages in thread
From: gregkh @ 2026-11-25 10:44 UTC (permalink / raw)
To: daejun7.park, amir73il, sashiko-bot; +Cc: stable
The patch below does not apply to the 6.18-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-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 86e2facd8630cc2fdec6ea80c53e370b26b441d9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112548-vowed-carded-1ef2@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 86e2facd8630cc2fdec6ea80c53e370b26b441d9 Mon Sep 17 00:00:00 2001
From: Daejun Park <daejun7.park@samsung.com>
Date: Thu, 12 Nov 2026 12:58:09 +0900
Subject: [PATCH] ovl: bump the impure dir version when linking a file with
origin
Linking a file with copy up origin into a non-merge impure dir does
not bump the dir version. readdir then reuses the impure dir cache
built before the link. It reports the upper inode number as d_ino of
the new link, not st_ino.
Pass whether the linked file has an origin to ovl_dir_modified(), as
rename and unlink do.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-98f207b6-3936-48e9-a40f-88f20be4db7b
Fixes: 4edb83bb1041 ("ovl: constant d_ino for non-merge dirs")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index e0a164e22d67..8fec18dc5fc7 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -368,7 +368,7 @@ static bool ovl_type_origin(struct dentry *dentry)
}
static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
- struct ovl_cattr *attr)
+ struct ovl_cattr *attr, bool origin)
{
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
@@ -393,7 +393,7 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
ovl_set_opaque(dentry, newdentry);
}
- ovl_dir_modified(dentry->d_parent, false);
+ ovl_dir_modified(dentry->d_parent, origin);
err = ovl_instantiate(dentry, inode, newdentry, !!attr->hardlink, NULL);
if (err)
goto out_cleanup;
@@ -491,7 +491,7 @@ static int ovl_set_upper_acl(struct ovl_fs *ofs, struct dentry *upperdentry,
}
static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
- struct ovl_cattr *cattr)
+ struct ovl_cattr *cattr, bool origin)
{
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
struct dentry *workdir = ovl_workdir(dentry);
@@ -582,7 +582,7 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
if (err)
goto out_cleanup_unlocked;
}
- ovl_dir_modified(dentry->d_parent, false);
+ ovl_dir_modified(dentry->d_parent, origin);
err = ovl_instantiate(dentry, inode, newdentry, hardlink, NULL);
if (err) {
ovl_cleanup(ofs, upperdir, newdentry);
@@ -647,12 +647,12 @@ DEFINE_CLASS(ovl_override_creator_creds,
static int ovl_create_handle_whiteouts(struct dentry *dentry,
struct inode *inode,
- struct ovl_cattr *attr)
+ struct ovl_cattr *attr, bool origin)
{
if (!ovl_dentry_is_whiteout(dentry))
- return ovl_create_upper(dentry, inode, attr);
+ return ovl_create_upper(dentry, inode, attr, origin);
- return ovl_create_over_whiteout(dentry, inode, attr);
+ return ovl_create_over_whiteout(dentry, inode, attr, origin);
}
static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
@@ -687,12 +687,14 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
*/
if (attr->hardlink)
- return ovl_create_handle_whiteouts(dentry, inode, attr);
+ return ovl_create_handle_whiteouts(dentry, inode, attr,
+ origin);
scoped_class(ovl_override_creator_creds, cred, original_creds, dentry, inode, attr->mode) {
if (IS_ERR(cred))
return PTR_ERR(cred);
- return ovl_create_handle_whiteouts(dentry, inode, attr);
+ return ovl_create_handle_whiteouts(dentry, inode, attr,
+ origin);
}
}
return err;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6.18.y 1/6] cred: add prepare credential guard
2026-11-25 10:44 FAILED: patch "[PATCH] ovl: bump the impure dir version when linking a file with" failed to apply to 6.18-stable tree gregkh
@ 2026-11-26 2:03 ` Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 2/6] ovl: port ovl_create_or_link() to cred guard Sasha Levin
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-26 2:03 UTC (permalink / raw)
To: stable; +Cc: Christian Brauner, Sasha Levin
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit c8ad3098e1272444b6c75910d6196a36f5c8bc17 ]
A lot of code uses the following pattern:
* prepare new credentials
* modify them for their use-case
* drop them
Support that easier with the new guard infrastructure.
Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-1-b447b82f2c9b@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 86e2facd8630 ("ovl: bump the impure dir version when linking a file with origin")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/linux/cred.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/cred.h b/include/linux/cred.h
index be2cd07b174c5..418c4a4ac2955 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -278,6 +278,11 @@ static inline void put_cred(const struct cred *cred)
put_cred_many(cred, 1);
}
+DEFINE_CLASS(prepare_creds,
+ struct cred *,
+ if (_T) put_cred(_T),
+ prepare_creds(), void)
+
DEFINE_FREE(put_cred, struct cred *, if (!IS_ERR_OR_NULL(_T)) put_cred(_T))
/**
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6.18.y 2/6] ovl: port ovl_create_or_link() to cred guard
2026-11-26 2:03 ` [PATCH 6.18.y 1/6] cred: add prepare credential guard Sasha Levin
@ 2026-11-26 2:03 ` Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 3/6] ovl: add ovl_override_creator_creds " Sasha Levin
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-26 2:03 UTC (permalink / raw)
To: stable; +Cc: Christian Brauner, Amir Goldstein, Sasha Levin
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit 8c9531edcf60014b7e36739697f5cc15d5e853a1 ]
Use the scoped ovl cred guard.
Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-3-b31603935724@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 86e2facd8630 ("ovl: bump the impure dir version when linking a file with origin")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/overlayfs/dir.c | 70 ++++++++++++++++++++--------------------------
1 file changed, 31 insertions(+), 39 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 8377f112feca3..935dc2187e6e2 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -617,52 +617,44 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
struct ovl_cattr *attr, bool origin)
{
int err;
- const struct cred *old_cred, *new_cred = NULL;
+ const struct cred *new_cred __free(put_cred) = NULL;
struct dentry *parent = dentry->d_parent;
- old_cred = ovl_override_creds(dentry->d_sb);
-
- /*
- * When linking a file with copy up origin into a new parent, mark the
- * new parent dir "impure".
- */
- if (origin) {
- err = ovl_set_impure(parent, ovl_dentry_upper(parent));
- if (err)
- goto out_revert_creds;
- }
-
- if (!attr->hardlink) {
+ scoped_class(override_creds_ovl, old_cred, dentry->d_sb) {
/*
- * In the creation cases(create, mkdir, mknod, symlink),
- * ovl should transfer current's fs{u,g}id to underlying
- * fs. Because underlying fs want to initialize its new
- * inode owner using current's fs{u,g}id. And in this
- * case, the @inode is a new inode that is initialized
- * in inode_init_owner() to current's fs{u,g}id. So use
- * the inode's i_{u,g}id to override the cred's fs{u,g}id.
- *
- * But in the other hardlink case, ovl_link() does not
- * create a new inode, so just use the ovl mounter's
- * fs{u,g}id.
+ * When linking a file with copy up origin into a new parent, mark the
+ * new parent dir "impure".
*/
- new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode,
- old_cred);
- err = PTR_ERR(new_cred);
- if (IS_ERR(new_cred)) {
- new_cred = NULL;
- goto out_revert_creds;
+ if (origin) {
+ err = ovl_set_impure(parent, ovl_dentry_upper(parent));
+ if (err)
+ return err;
}
- }
- if (!ovl_dentry_is_whiteout(dentry))
- err = ovl_create_upper(dentry, inode, attr);
- else
- err = ovl_create_over_whiteout(dentry, inode, attr);
+ if (!attr->hardlink) {
+ /*
+ * In the creation cases(create, mkdir, mknod, symlink),
+ * ovl should transfer current's fs{u,g}id to underlying
+ * fs. Because underlying fs want to initialize its new
+ * inode owner using current's fs{u,g}id. And in this
+ * case, the @inode is a new inode that is initialized
+ * in inode_init_owner() to current's fs{u,g}id. So use
+ * the inode's i_{u,g}id to override the cred's fs{u,g}id.
+ *
+ * But in the other hardlink case, ovl_link() does not
+ * create a new inode, so just use the ovl mounter's
+ * fs{u,g}id.
+ */
+ new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode, old_cred);
+ if (IS_ERR(new_cred))
+ return PTR_ERR(new_cred);
+ }
-out_revert_creds:
- ovl_revert_creds(old_cred);
- put_cred(new_cred);
+ if (!ovl_dentry_is_whiteout(dentry))
+ return ovl_create_upper(dentry, inode, attr);
+
+ return ovl_create_over_whiteout(dentry, inode, attr);
+ }
return err;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6.18.y 3/6] ovl: add ovl_override_creator_creds cred guard
2026-11-26 2:03 ` [PATCH 6.18.y 1/6] cred: add prepare credential guard Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 2/6] ovl: port ovl_create_or_link() to cred guard Sasha Levin
@ 2026-11-26 2:03 ` Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 4/6] ovl: reflow ovl_create_or_link() Sasha Levin
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-26 2:03 UTC (permalink / raw)
To: stable; +Cc: Christian Brauner, Amir Goldstein, Sasha Levin
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit f37b334728814b14745e15d46f9eab73750b67ec ]
The current code to override credentials for creation operations is
pretty difficult to understand. We effectively override the credentials
twice:
(1) override with the mounter's credentials
(2) copy the mounts credentials and override the fs{g,u}id with the inode {u,g}id
And then we elide the revert because it would be an idempotent revert.
That elision doesn't buy us anything anymore though because I've made it
all work without any reference counting anyway. All it does is mix the
two credential overrides together.
We can use a cleanup guard to clarify the creation codepaths and make
them easier to understand.
This just introduces the cleanup guard keeping the patch reviewable.
We'll convert the caller in follow-up patches and then drop the
duplicated code.
Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-prepare-v2-1-bd1c97a36d7b@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 86e2facd8630 ("ovl: bump the impure dir version when linking a file with origin")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/overlayfs/dir.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 935dc2187e6e2..058e18331dd47 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -580,6 +580,42 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
goto out_dput;
}
+static const struct cred *ovl_override_creator_creds(struct dentry *dentry, struct inode *inode, umode_t mode)
+{
+ int err;
+
+ if (WARN_ON_ONCE(current->cred != ovl_creds(dentry->d_sb)))
+ return ERR_PTR(-EINVAL);
+
+ CLASS(prepare_creds, override_cred)();
+ if (!override_cred)
+ return ERR_PTR(-ENOMEM);
+
+ override_cred->fsuid = inode->i_uid;
+ override_cred->fsgid = inode->i_gid;
+
+ err = security_dentry_create_files_as(dentry, mode, &dentry->d_name,
+ current->cred, override_cred);
+ if (err)
+ return ERR_PTR(err);
+
+ return override_creds(no_free_ptr(override_cred));
+}
+
+static void ovl_revert_creator_creds(const struct cred *old_cred)
+{
+ const struct cred *override_cred;
+
+ override_cred = revert_creds(old_cred);
+ put_cred(override_cred);
+}
+
+DEFINE_CLASS(ovl_override_creator_creds,
+ const struct cred *,
+ if (!IS_ERR_OR_NULL(_T)) ovl_revert_creator_creds(_T),
+ ovl_override_creator_creds(dentry, inode, mode),
+ struct dentry *dentry, struct inode *inode, umode_t mode)
+
static const struct cred *ovl_setup_cred_for_create(struct dentry *dentry,
struct inode *inode,
umode_t mode,
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6.18.y 4/6] ovl: reflow ovl_create_or_link()
2026-11-26 2:03 ` [PATCH 6.18.y 1/6] cred: add prepare credential guard Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 2/6] ovl: port ovl_create_or_link() to cred guard Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 3/6] ovl: add ovl_override_creator_creds " Sasha Levin
@ 2026-11-26 2:03 ` Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 5/6] ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 6/6] ovl: bump the impure dir version when linking a file with origin Sasha Levin
4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-26 2:03 UTC (permalink / raw)
To: stable; +Cc: Christian Brauner, Amir Goldstein, Sasha Levin
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit d6ef072d09b2341e606aeeaf14c3510dec329c63 ]
Reflow the creation routine in preparation of porting it to a guard.
Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-prepare-v2-3-bd1c97a36d7b@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 86e2facd8630 ("ovl: bump the impure dir version when linking a file with origin")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/overlayfs/dir.c | 51 +++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 058e18331dd47..c9871c111a84e 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -649,6 +649,16 @@ static const struct cred *ovl_setup_cred_for_create(struct dentry *dentry,
return override_cred;
}
+static int ovl_create_handle_whiteouts(struct dentry *dentry,
+ struct inode *inode,
+ struct ovl_cattr *attr)
+{
+ if (!ovl_dentry_is_whiteout(dentry))
+ return ovl_create_upper(dentry, inode, attr);
+
+ return ovl_create_over_whiteout(dentry, inode, attr);
+}
+
static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
struct ovl_cattr *attr, bool origin)
{
@@ -667,29 +677,28 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
return err;
}
- if (!attr->hardlink) {
- /*
- * In the creation cases(create, mkdir, mknod, symlink),
- * ovl should transfer current's fs{u,g}id to underlying
- * fs. Because underlying fs want to initialize its new
- * inode owner using current's fs{u,g}id. And in this
- * case, the @inode is a new inode that is initialized
- * in inode_init_owner() to current's fs{u,g}id. So use
- * the inode's i_{u,g}id to override the cred's fs{u,g}id.
- *
- * But in the other hardlink case, ovl_link() does not
- * create a new inode, so just use the ovl mounter's
- * fs{u,g}id.
- */
- new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode, old_cred);
- if (IS_ERR(new_cred))
- return PTR_ERR(new_cred);
- }
+ /*
+ * In the creation cases(create, mkdir, mknod, symlink),
+ * ovl should transfer current's fs{u,g}id to underlying
+ * fs. Because underlying fs want to initialize its new
+ * inode owner using current's fs{u,g}id. And in this
+ * case, the @inode is a new inode that is initialized
+ * in inode_init_owner() to current's fs{u,g}id. So use
+ * the inode's i_{u,g}id to override the cred's fs{u,g}id.
+ *
+ * But in the other hardlink case, ovl_link() does not
+ * create a new inode, so just use the ovl mounter's
+ * fs{u,g}id.
+ */
+
+ if (attr->hardlink)
+ return ovl_create_handle_whiteouts(dentry, inode, attr);
- if (!ovl_dentry_is_whiteout(dentry))
- return ovl_create_upper(dentry, inode, attr);
+ new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode, old_cred);
+ if (IS_ERR(new_cred))
+ return PTR_ERR(new_cred);
- return ovl_create_over_whiteout(dentry, inode, attr);
+ return ovl_create_handle_whiteouts(dentry, inode, attr);
}
return err;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6.18.y 5/6] ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard
2026-11-26 2:03 ` [PATCH 6.18.y 1/6] cred: add prepare credential guard Sasha Levin
` (2 preceding siblings ...)
2026-11-26 2:03 ` [PATCH 6.18.y 4/6] ovl: reflow ovl_create_or_link() Sasha Levin
@ 2026-11-26 2:03 ` Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 6/6] ovl: bump the impure dir version when linking a file with origin Sasha Levin
4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-26 2:03 UTC (permalink / raw)
To: stable; +Cc: Christian Brauner, Amir Goldstein, Sasha Levin
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit e566bff963220ba0f740da42d46dd55c34ef745e ]
This clearly indicates the double-credential override and makes the code
a lot easier to grasp with one glance.
Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-prepare-v2-5-bd1c97a36d7b@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 86e2facd8630 ("ovl: bump the impure dir version when linking a file with origin")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/overlayfs/dir.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index c9871c111a84e..43a9866428b38 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -663,10 +663,9 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
struct ovl_cattr *attr, bool origin)
{
int err;
- const struct cred *new_cred __free(put_cred) = NULL;
struct dentry *parent = dentry->d_parent;
- scoped_class(override_creds_ovl, old_cred, dentry->d_sb) {
+ with_ovl_creds(dentry->d_sb) {
/*
* When linking a file with copy up origin into a new parent, mark the
* new parent dir "impure".
@@ -694,11 +693,11 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
if (attr->hardlink)
return ovl_create_handle_whiteouts(dentry, inode, attr);
- new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode, old_cred);
- if (IS_ERR(new_cred))
- return PTR_ERR(new_cred);
-
- return ovl_create_handle_whiteouts(dentry, inode, attr);
+ scoped_class(ovl_override_creator_creds, cred, dentry, inode, attr->mode) {
+ if (IS_ERR(cred))
+ return PTR_ERR(cred);
+ return ovl_create_handle_whiteouts(dentry, inode, attr);
+ }
}
return err;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6.18.y 6/6] ovl: bump the impure dir version when linking a file with origin
2026-11-26 2:03 ` [PATCH 6.18.y 1/6] cred: add prepare credential guard Sasha Levin
` (3 preceding siblings ...)
2026-11-26 2:03 ` [PATCH 6.18.y 5/6] ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard Sasha Levin
@ 2026-11-26 2:03 ` Sasha Levin
4 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2026-11-26 2:03 UTC (permalink / raw)
To: stable; +Cc: Daejun Park, Sashiko, Amir Goldstein, Sasha Levin
From: Daejun Park <daejun7.park@samsung.com>
[ Upstream commit 86e2facd8630cc2fdec6ea80c53e370b26b441d9 ]
Linking a file with copy up origin into a non-merge impure dir does
not bump the dir version. readdir then reuses the impure dir cache
built before the link. It reports the upper inode number as d_ino of
the new link, not st_ino.
Pass whether the linked file has an origin to ovl_dir_modified(), as
rename and unlink do.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-98f207b6-3936-48e9-a40f-88f20be4db7b
Fixes: 4edb83bb1041 ("ovl: constant d_ino for non-merge dirs")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/overlayfs/dir.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 43a9866428b38..d443c3169dad5 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -355,7 +355,7 @@ static bool ovl_type_origin(struct dentry *dentry)
}
static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
- struct ovl_cattr *attr)
+ struct ovl_cattr *attr, bool origin)
{
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
struct dentry *upperdir = ovl_dentry_upper(dentry->d_parent);
@@ -378,7 +378,7 @@ static int ovl_create_upper(struct dentry *dentry, struct inode *inode,
ovl_set_opaque(dentry, newdentry);
}
- ovl_dir_modified(dentry->d_parent, false);
+ ovl_dir_modified(dentry->d_parent, origin);
err = ovl_instantiate(dentry, inode, newdentry, !!attr->hardlink, NULL);
if (err)
goto out_cleanup;
@@ -471,7 +471,7 @@ static int ovl_set_upper_acl(struct ovl_fs *ofs, struct dentry *upperdentry,
}
static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
- struct ovl_cattr *cattr)
+ struct ovl_cattr *cattr, bool origin)
{
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
struct dentry *workdir = ovl_workdir(dentry);
@@ -557,7 +557,7 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode,
if (err)
goto out_cleanup_unlocked;
}
- ovl_dir_modified(dentry->d_parent, false);
+ ovl_dir_modified(dentry->d_parent, origin);
err = ovl_instantiate(dentry, inode, newdentry, hardlink, NULL);
if (err) {
ovl_cleanup(ofs, upperdir, newdentry);
@@ -651,12 +651,12 @@ static const struct cred *ovl_setup_cred_for_create(struct dentry *dentry,
static int ovl_create_handle_whiteouts(struct dentry *dentry,
struct inode *inode,
- struct ovl_cattr *attr)
+ struct ovl_cattr *attr, bool origin)
{
if (!ovl_dentry_is_whiteout(dentry))
- return ovl_create_upper(dentry, inode, attr);
+ return ovl_create_upper(dentry, inode, attr, origin);
- return ovl_create_over_whiteout(dentry, inode, attr);
+ return ovl_create_over_whiteout(dentry, inode, attr, origin);
}
static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
@@ -691,12 +691,14 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
*/
if (attr->hardlink)
- return ovl_create_handle_whiteouts(dentry, inode, attr);
+ return ovl_create_handle_whiteouts(dentry, inode, attr,
+ origin);
scoped_class(ovl_override_creator_creds, cred, dentry, inode, attr->mode) {
if (IS_ERR(cred))
return PTR_ERR(cred);
- return ovl_create_handle_whiteouts(dentry, inode, attr);
+ return ovl_create_handle_whiteouts(dentry, inode, attr,
+ origin);
}
}
return err;
--
2.53.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-26 2:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 10:44 FAILED: patch "[PATCH] ovl: bump the impure dir version when linking a file with" failed to apply to 6.18-stable tree gregkh
2026-11-26 2:03 ` [PATCH 6.18.y 1/6] cred: add prepare credential guard Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 2/6] ovl: port ovl_create_or_link() to cred guard Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 3/6] ovl: add ovl_override_creator_creds " Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 4/6] ovl: reflow ovl_create_or_link() Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 5/6] ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard Sasha Levin
2026-11-26 2:03 ` [PATCH 6.18.y 6/6] ovl: bump the impure dir version when linking a file with origin Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox