Skip to content

Commit b9f0897

Browse files
rchatrebp3tk0v
authored andcommitted
fs/resctrl: Fix double-add of pseudo-locked region's RMID to free list
A pseudo-locked group's RMID is freed when it is created. On unmount rmdir_all_sub() unconditionally frees all RMID of all groups, resulting in a double-free of the pseudo-locked group's RMID. The consequence of this is that the original free results in the pseudo-locked group's RMID being added to the rmid_free_lru linked list and the second free then attempts to add the same RMID entry to the rmid_free_lru again. Do not double-free a pseudo-locked group's RMID. Fixes: e0bdfe8 ("x86/intel_rdt: Support creation/removal of pseudo-locked region") Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Cc: <stable@kernel.org> Link: https://patch.msgid.link/551432dd7e624a862b8e58314c38aaba0afff3e9.1783377598.git.reinette.chatre@intel.com
1 parent 52fce64 commit b9f0897

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

fs/resctrl/rdtgroup.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3084,10 +3084,6 @@ static void rmdir_all_sub(void)
30843084
if (rdtgrp == &rdtgroup_default)
30853085
continue;
30863086

3087-
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP ||
3088-
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED)
3089-
rdtgroup_pseudo_lock_remove(rdtgrp);
3090-
30913087
/*
30923088
* Give any CPUs back to the default group. We cannot copy
30933089
* cpu_online_mask because a CPU might have executed the
@@ -3098,7 +3094,13 @@ static void rmdir_all_sub(void)
30983094

30993095
rdtgroup_unassign_cntrs(rdtgrp);
31003096

3101-
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
3097+
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP ||
3098+
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
3099+
rdtgroup_pseudo_lock_remove(rdtgrp);
3100+
} else {
3101+
/* Pseudo-locked group's RMID is freed during setup. */
3102+
free_rmid(rdtgrp->closid, rdtgrp->mon.rmid);
3103+
}
31023104

31033105
kernfs_remove(rdtgrp->kn);
31043106
list_del(&rdtgrp->rdtgroup_list);

0 commit comments

Comments
 (0)