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: <1284471892-8433-1-git-send-email-sgruszka@redhat.com>
Date:	Tue, 14 Sep 2010 15:44:52 +0200
From:	Stanislaw Gruszka <sgruszka@...hat.com>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	linux-kernel@...r.kernel.org,
	Stanislaw Gruszka <sgruszka@...hat.com>,
	Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>,
	Peter Zijlstra <peterz@...radead.org>,
	stable@...nel.org.#.2.6.32.19+ (partially), 2.6.33+@...hat.com
Subject: [PATCH] sched: fix user time incorrectly accounted as system time on 32 bit

We have 32 bit variable overflow possibility when multiply in
task_times() and thread_group_times() functions. If overflow happens
calculated scaled utime value become wrongly small and scaled stime
wrongly big.

Reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=633037
https://bugzilla.kernel.org/show_bug.cgi?id=16559

Reported-by: Michael Chapman <redhat-bugzilla@...y.puzzling.org>
Reported-by: Ciriaco Garcia de Celis <sysman@...erpilot.com>
Cc: Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: stable@...nel.org  # 2.6.32.19+ (partially), 2.6.33+
Signed-off-by: Stanislaw Gruszka <sgruszka@...hat.com>
---
 kernel/sched.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 09b574e..eee9470 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3507,9 +3507,9 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
 	rtime = nsecs_to_cputime(p->se.sum_exec_runtime);
 
 	if (total) {
-		u64 temp;
+		u64 temp = rtime;
 
-		temp = (u64)(rtime * utime);
+		temp *= utime;
 		do_div(temp, total);
 		utime = (cputime_t)temp;
 	} else
@@ -3540,9 +3540,9 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
 	rtime = nsecs_to_cputime(cputime.sum_exec_runtime);
 
 	if (total) {
-		u64 temp;
+		u64 temp = rtime;
 
-		temp = (u64)(rtime * cputime.utime);
+		temp *= cputime.utime;
 		do_div(temp, total);
 		utime = (cputime_t)temp;
 	} else
-- 
1.7.1

--
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