Directory entries can provide an exists hook to hide themselves from readdir, 
but procfs_dir_lookup ignored that hook and still allowed such entries to be 
opened directly by name.

Return ENOENT when the matched entry is currently hidden.

Signed-off-by: Bradley Morgan <[email protected]>
---
 procfs/procfs_dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/procfs/procfs_dir.c b/procfs/procfs_dir.c
index c250aa48..e570f32a 100644
--- a/procfs/procfs_dir.c
+++ b/procfs/procfs_dir.c
@@ -81,6 +81,8 @@ procfs_dir_lookup (void *hook, const char *name, struct node 
**np)
   for (ent = dir->ops->entries; ent->name && strcmp (name, ent->name); ent++);
   if (! ent->name)
     return ENOENT;
+  if (! entry_exists (dir, ent))
+    return ENOENT;
 
   if (ent->ops.make_node)
     *np = ent->ops.make_node (dir->hook, ent->hook);
@@ -131,4 +133,3 @@ procfs_dir_make_node (const struct procfs_dir_ops *dir_ops, 
void *dir_hook)
 
   return procfs_make_node (&ops, dir);
 }
-
-- 
2.53.0


Reply via email to