Re: [PATCH v3 4/9] fs/resctrl: Fix deadlock for errors during mount
From: Ben Horgan
Date: Thu May 28 2026 - 06:13:55 EST
Hi Reinette,
On 5/22/26 20:15, Reinette Chatre wrote:
> 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. 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()
>
> Add resctrl_unmount() helper to keep code consistent between the
> rdt_get_tree() failure path and a normal unmount.
>
> Fixes: 5ff193fbde20 ("x86/intel_rdt: Add basic resctrl filesystem support")
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Closes: https://sashiko.dev/#/patchset/20260429184858.36423-1-tony.luck%40intel.com [1]
> Co-developed-by: Tony Luck <tony.luck@xxxxxxxxx>
> Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
> Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Looks good to me.
Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>
Thanks,
Ben