[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240705062621.630604-3-eugen.hristev@collabora.com>
Date: Fri, 5 Jul 2024 09:26:21 +0300
From: Eugen Hristev <eugen.hristev@...labora.com>
To: viro@...iv.linux.org.uk,
brauner@...nel.org,
tytso@....edu,
linux-ext4@...r.kernel.org
Cc: jack@...e.cz,
adilger.kernel@...ger.ca,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
krisman@...e.de,
kernel@...labora.com,
shreeya.patel@...labora.com,
Eugen Hristev <eugen.hristev@...labora.com>
Subject: [PATCH 2/2] ext4: in lookup call d_add_ci if there is a case mismatch
In lookup function, if we have a file match but not a case match in the
case-insensitive case, call d_add_ci to store the real filename into cache
instead of the case variant of the name that was looked up.
This avoids exposing into user space (e.g. /proc/self/cwd) internal cache
data.
Signed-off-by: Eugen Hristev <eugen.hristev@...labora.com>
---
fs/ext4/namei.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index e6769b97a970..0676c21e1622 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1834,6 +1834,19 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
return NULL;
}
+ /* Create a case-insensitive cache entry with the real
+ * name stored, in case our search pattern differs
+ * in terms of case.
+ */
+ if (inode && IS_CASEFOLDED(dir) &&
+ memcmp(de->name, dentry->d_name.name, de->name_len)) {
+ struct qstr dname;
+
+ dname.len = de->name_len;
+ dname.name = de->name;
+ return d_add_ci(dentry, inode, &dname);
+ }
+
return d_splice_alias(inode, dentry);
}
--
2.34.1
Powered by blists - more mailing lists