Skip to content

Commit d69697a

Browse files
Shawn Wangsmb49
authored andcommitted
x86/resctrl: Only show tasks' pid in current pid namespace
BugLink: https://bugs.launchpad.net/bugs/2032689 [ Upstream commit 2997d94 ] When writing a task id to the "tasks" file in an rdtgroup, rdtgroup_tasks_write() treats the pid as a number in the current pid namespace. But when reading the "tasks" file, rdtgroup_tasks_show() shows the list of global pids from the init namespace, which is confusing and incorrect. To be more robust, let the "tasks" file only show pids in the current pid namespace. Fixes: e02737d ("x86/intel_rdt: Add tasks files") Signed-off-by: Shawn Wang <shawnwang@linux.alibaba.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Reinette Chatre <reinette.chatre@intel.com> Acked-by: Fenghua Yu <fenghua.yu@intel.com> Tested-by: Reinette Chatre <reinette.chatre@intel.com> Link: https://lore.kernel.org/all/20230116071246.97717-1-shawnwang@linux.alibaba.com/ Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 6be2e11 commit d69697a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,15 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
731731
static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
732732
{
733733
struct task_struct *p, *t;
734+
pid_t pid;
734735

735736
rcu_read_lock();
736737
for_each_process_thread(p, t) {
737-
if (is_closid_match(t, r) || is_rmid_match(t, r))
738-
seq_printf(s, "%d\n", t->pid);
738+
if (is_closid_match(t, r) || is_rmid_match(t, r)) {
739+
pid = task_pid_vnr(t);
740+
if (pid)
741+
seq_printf(s, "%d\n", pid);
742+
}
739743
}
740744
rcu_read_unlock();
741745
}

0 commit comments

Comments
 (0)