[Devel] [PATCH RHEL9 COMMIT] ve/kernfs: handle negative dcache entries in kernfs_iop_lookup()
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Feb 25 21:17:58 MSK 2022
The commit is pushed to "branch-rh9-5.14.0-42.vz9.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-42.vz9.14.2
------>
commit fceec5e008b12e16f75c635a2a5cf3ac7bc9927d
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date: Thu Feb 24 20:14:13 2022 +0300
ve/kernfs: handle negative dcache entries in kernfs_iop_lookup()
After ms comit c7e7c04274b1 ("kernfs: use VFS negative dentry caching")
kernfs_iop_lookup() is intended to handle negative dcache entries,
thus kernfs_find_ns() might return NULL and kernfs_d_visible() crashes.
Make sure kernfs_d_visible() is called with non-zero kn.
Fixes: 62c36c3dbf08 ("ve/kernfs: hide forbidden entries in container")
https://jira.sw.ru/browse/PSBM-138339
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
fs/kernfs/dir.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index efd6ec30e287..26c0849c609f 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1118,11 +1118,6 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
kn = kernfs_find_ns(parent, dentry->d_name.name, ns);
- if(!kernfs_d_visible(kn, kernfs_info(dentry->d_sb))) {
- up_read(&kernfs_rwsem);
- return NULL;
- }
-
/* attach dentry and inode */
if (kn) {
/* Inactive nodes are invisible to the VFS so don't
@@ -1132,6 +1127,12 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
up_read(&kernfs_rwsem);
return NULL;
}
+
+ if (!kernfs_d_visible(kn, kernfs_info(dentry->d_sb))) {
+ up_read(&kernfs_rwsem);
+ return NULL;
+ }
+
inode = kernfs_get_inode(dir->i_sb, kn);
if (!inode)
inode = ERR_PTR(-ENOMEM);
More information about the Devel
mailing list