Re: [PATCH v2 4/5] fs/resctrl: Fix deadlock for errors during mount

From: Reinette Chatre

Date: Tue May 19 2026 - 00:04:19 EST




On 5/18/26 1:54 PM, Babu Moger wrote:
> Hi Tony,
>
>
> On 5/15/26 14:39, Tony Luck wrote:
>> From: Reinette Chatre <reinette.chatre@xxxxxxxxx>
>>
>> Sashiko noticed[1] a deadlock in the resctrl mount code.
>>
>> rdt_get_tree() acquires rdtgroup_mutex before calling kernfs_get_tree(). If
>> superblock setup fails inside kernfs_get_tree(), the VFS calls kill_sb on
>> the same thread before the call returns.  rdt_kill_sb() unconditionally
>> attempts to acquire rdtgroup_mutex and deadlock occurs.
>>
>> Move the call to kernfs_get_tree() outside of locks.
>>
>> Add resctrl_unmount() helper to keep code consistent between the
>> rdt_get_tree() failure path and a normal unmount.
>>
>> If kernfs_get_tree() fails and ctx->kfc.new_sb_created is set, then rdt_kill_sb()
>> has already been called and no further cleanup is needed.
>>
>> Add an extra hold in this error path on rdtgroup_default.kn to defend against
>> other races destroying the root which is then dereferenced in kernfs_kill_sb()
>>
>> Fixes: 5ff193fbde20 ("x86/intel_rdt: Add basic resctrl filesystem support")
>> Co-developed-by: Tony Luck <tony.luck@xxxxxxxxx>
>> Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
>
> This should be
>
> Co-developed-by: Tony Luck <tony.luck@xxxxxxxxx>
> Signed-off-by:   Tony Luck <tony.luck@xxxxxxxxx>
> Signed-off-by:   Reinette Chatre <reinette.chatre@xxxxxxxxx>

I have not yet given my Signed-off-by to these patches. I am still wrangling with
sashiko's most recent concerns with the areas touched by this submission
https://sashiko.dev/#/patchset/20260515193944.15114-1-tony.luck%40intel.com

Reinette