Re: [PATCH 4/4] kernfs: Remove kernfs_rwsem from dentry revalidation

From: Ian Kent

Date: Mon Sep 14 2026 - 22:39:39 EST


On 12/9/26 11:28, Sandeep Dhavale wrote:
Hi Shakeel,
I don't see how reclaim can set dentry->d_inode = NULL for a dentry with
elevated dentry->d_lockref.count because kernfs_dop_revalidate gets the dentry
whose dentry->d_lockref.count is elevated. Reclaim specifically skips such
dentries.
Thank you for your input! That may explain why I am unable to reproduce led by
memory stress narrative. Let me attempt to reproduce this first and I
will provide an update.

It looks possible the dentry isn't negative, instead it might be possible

it's a use after free of the inode. There are functions that are called

directly by file systems that use kernfs.


I always thought that was the reason for the lock, not so much a need to

synchronise with the VFS (eg. in ref-walk mode it's likely the inode read

lock is held).


I wonder if there's a concurrent remove going on when this happens?


You could enable debug logging and see if you can see any node removal log

messages. The logging isn't very chatty so it might be difficult to get

further context from it but it could provide a lead to follow up on.


Ian