lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1578500026-21152-1-git-send-email-xiaochen.shen@intel.com>
Date:   Thu,  9 Jan 2020 00:13:46 +0800
From:   Xiaochen Shen <xiaochen.shen@...el.com>
To:     tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
        tony.luck@...el.com, fenghua.yu@...el.com,
        reinette.chatre@...el.com
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org, pei.p.jia@...el.com,
        xiaochen.shen@...el.com
Subject: [PATCH] x86/resctrl: Take care of PF_EXITING task in callback

When writing a pid to file "tasks", a callback function move_myself()
is queued to this task to be called when the task returns from kernel
mode or exits. The purpose of move_myself() is to activate the newly
assigned closid and/or rmid associated with this task. This activation
is done by calling resctrl_sched_in() from move_myself(), the same
function that is called when switching to this task.

If this work is successfully queued but then the task enters PF_EXITING
status (e.g., receiving signal SIGKILL, SIGTERM) prior to the execution
of the callback move_myself() then move_myself() still calls
resctrl_sched_in() since the task status is not currently considered.

When a task is exiting then the data structure of the task itself will
be freed soon, calling resctrl_sched_in() to write the register that
control's the task's resources is unnecessary and it implies extra
performance overhead.

Add check on task status in move_myself() and return immediately if the
task is PF_EXITING.

Signed-off-by: Xiaochen Shen <xiaochen.shen@...el.com>
Reviewed-by: Reinette Chatre <reinette.chatre@...el.com>
---
 arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
index 2e3b06d6bbc6..205925d802d8 100644
--- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c
+++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c
@@ -532,11 +532,15 @@ static void move_myself(struct callback_head *head)
 		kfree(rdtgrp);
 	}
 
+	if (unlikely(current->flags & PF_EXITING))
+		goto out;
+
 	preempt_disable();
 	/* update PQR_ASSOC MSR to make resource group go into effect */
 	resctrl_sched_in();
 	preempt_enable();
 
+out:
 	kfree(callback);
 }
 
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ