From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751612AbdIRWSw (ORCPT ); Mon, 18 Sep 2017 18:18:52 -0400 Received: from mga14.intel.com ([192.55.52.115]:48420 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751480AbdIRWSs (ORCPT ); Mon, 18 Sep 2017 18:18:48 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,414,1500966000"; d="scan'208";a="1173474332" From: "Luck, Tony" To: Thomas Gleixner Cc: Tony Luck , linux-kernel@vger.kernel.org, Boris Petkov , Fenghua Yu , Reinette Chatre , Steven Rostedt , Vikas Shivappa Subject: [PATCH 3/5] x86/intel_rdt: Add diagnostics when writing the tasks file Date: Mon, 18 Sep 2017 15:18:41 -0700 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Luck About the only tricky case is trying to move a task into a monitor group that is a subdirectory of a different control group. But cover the simple cases too. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 6a2cd89fa9de..c54189a1b54e 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -455,6 +455,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk, */ atomic_dec(&rdtgrp->waitcount); kfree(callback); + seq_buf_puts(&last_cmd_status, "task exited\n"); } else { /* * For ctrl_mon groups move both closid and rmid. @@ -465,10 +466,13 @@ static int __rdtgroup_move_task(struct task_struct *tsk, tsk->closid = rdtgrp->closid; tsk->rmid = rdtgrp->mon.rmid; } else if (rdtgrp->type == RDTMON_GROUP) { - if (rdtgrp->mon.parent->closid == tsk->closid) + if (rdtgrp->mon.parent->closid == tsk->closid) { tsk->rmid = rdtgrp->mon.rmid; - else + } else { + seq_buf_puts(&last_cmd_status, + "Can't move task to different control group\n"); ret = -EINVAL; + } } } return ret; @@ -487,8 +491,11 @@ static int rdtgroup_task_write_permission(struct task_struct *task, */ if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && !uid_eq(cred->euid, tcred->uid) && - !uid_eq(cred->euid, tcred->suid)) + !uid_eq(cred->euid, tcred->suid)) { + seq_buf_printf(&last_cmd_status, + "No permission to move task %d\n", task->pid); ret = -EPERM; + } put_cred(tcred); return ret; @@ -505,6 +512,7 @@ static int rdtgroup_move_task(pid_t pid, struct rdtgroup *rdtgrp, tsk = find_task_by_vpid(pid); if (!tsk) { rcu_read_unlock(); + seq_buf_printf(&last_cmd_status, "No task %d\n", pid); return -ESRCH; } } else { @@ -532,6 +540,7 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of, if (kstrtoint(strstrip(buf), 0, &pid) || pid < 0) return -EINVAL; rdtgrp = rdtgroup_kn_lock_live(of->kn); + seq_buf_clear(&last_cmd_status); if (rdtgrp) ret = rdtgroup_move_task(pid, rdtgrp, of); -- 2.11.0