Re: [PATCH v6 08/10] fs/resctrl: Prevent deadlock and use-after-free in info file handlers
From: Reinette Chatre
Date: Tue Jul 07 2026 - 19:55:11 EST
Hi Tony,
On 7/7/26 4:33 PM, Luck, Tony wrote:
> On Mon, Jul 06, 2026 at 03:46:28PM -0700, Reinette Chatre wrote:
>> @@ -1020,9 +1030,15 @@ static int rdt_min_cbm_bits_show(struct kernfs_open_file *of,
>> struct seq_file *seq, void *v)
>> {
>> struct resctrl_schema *s = rdt_kn_parent_priv(of->kn);
>> - struct rdt_resource *r = s->res;
>> + struct rdt_resource *r;
>> +
>
> Extra blank line added here.
>>
>> + if (!info_kn_lock(of->kn))
>> + return -ENOENT;
>> + r = s->res;
>> seq_printf(seq, "%u\n", r->cache.min_cbm_bits);
>> + info_kn_unlock(of->kn);
>> +
>> return 0;
>> }
>>
>
> ...
>
>> @@ -1652,8 +1718,8 @@ static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtid
>> struct rdt_l3_mon_domain *dom;
>> bool sep = false;
>>
>> - cpus_read_lock();
>> - mutex_lock(&rdtgroup_mutex);
>> + lockdep_assert_cpus_held();
>> + lockdep_assert_held(&rdtgroup_mutex);
>>
>> list_for_each_entry_rcu(dom, &r->mon_domains, hdr.list, lockdep_is_cpus_held()) {
>> if (sep)
>> @@ -1670,8 +1736,6 @@ static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtid
>> }
>> seq_puts(s, "\n");
>>
>> - mutex_unlock(&rdtgroup_mutex);
>> - cpus_read_unlock();
>>
>
> Extra blank line here after deleting those two lines.
>
Thank you very much. I plan to send a new version of this series based on -rc3 next week unless
I learn about a better way to handle this before then.
Reinette