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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070921233055.21607.12387.stgit@localhost.localdomain>
Date:	Sat, 22 Sep 2007 01:30:55 +0200
From:	Guillaume Chazarain <guichaz@...oo.fr>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Oleg Nesterov <oleg@...sign.ru>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>,
	Jonathan Lim <jlim@....com>,
	Jay Lan <jlan@...ulhu.engr.sgi.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH 3/3] taskstats: fix stats->ac_exitcode to work on threads and
	use group_exit_code

Threads also have an exit code on their own, so report it in
TASKSTATS_CMD_ATTR_PID.

For TASKSTATS_CMD_ATTR_TGID, instead of relying only on the exit code of the
leader, we use task->signal->group_exit_code if not null as suggested by
Oleg Nesterov.

Also, document that as of this patch, fill_threadgroup() must be called after
add_tsk() as it may overwrite some stats.

Signed-off-by: Guillaume Chazarain <guichaz@...oo.fr>
Cc: Balbir Singh <balbir@...ibm.com>
Cc: Jay Lan <jlan@...r.sgi.com>
Cc: Jonathan Lim <jlim@....com>
Cc: Oleg Nesterov <oleg@...sign.ru>
---

 kernel/taskstats.c |    3 +++
 kernel/tsacct.c    |   12 +++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 42d3110..24d7f62 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -181,6 +181,9 @@ static void send_cpu_listeners(struct sk_buff *skb,
  *	memory usage), so are taken from the group leader.
  * XXX_threadgroup() methods deal with the first type while XXX_add_tsk() with
  * the second.
+ *
+ * fill_threadgroup() may overwrite stats from add_tsk(), so it must be called
+ * after add_tsk().
  */
 static void fill_threadgroup(struct taskstats *stats, struct task_struct *task,
 			     bool tg_stats)
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 24056aa..526b134 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -44,6 +44,8 @@ static void fill_wall_times(struct taskstats *stats, struct task_struct *tsk)
 void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task,
 			    bool tg_stats)
 {
+	int group_exit_code;
+
 	BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
 
 	rcu_read_lock();
@@ -53,11 +55,11 @@ void bacct_fill_threadgroup(struct taskstats *stats, struct task_struct *task,
 
 	fill_wall_times(stats, task);
 
-	if (thread_group_leader(task)) {
-		stats->ac_exitcode = task->exit_code;
-		if (task->flags & PF_FORKNOEXEC)
-			stats->ac_flag |= AFORK;
-	}
+	if (thread_group_leader(task) && (task->flags & PF_FORKNOEXEC))
+		stats->ac_flag |= AFORK;
+
+	group_exit_code = tg_stats ? task->signal->group_exit_code : 0;
+	stats->ac_exitcode	= group_exit_code ? : task->exit_code;
 
 	stats->ac_nice		= task_nice(task);
 	stats->ac_sched		= task->policy;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ