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: <20200717060849.12469-1-liwei.song@windriver.com>
Date:   Fri, 17 Jul 2020 14:08:49 +0800
From:   Liwei Song <liwei.song@...driver.com>
To:     Len Brown <lenb@...nel.org>, <linux-pm@...r.kernel.org>
CC:     <linux-kernel@...r.kernel.org>, <liwei.song@...driver.com>
Subject: [PATCH] tools/power turbostat: call pread64 in kernel directly

with 32-bit rootfs, the offset may out of range when set it
to 0xc0010299, define it as "unsigned long long" type and
call pread64 directly in kernel.

Signed-off-by: Liwei Song <liwei.song@...driver.com>
---
 tools/power/x86/turbostat/turbostat.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 33b370865d16..4c5cdfcb5721 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -33,6 +33,7 @@
 #include <sys/capability.h>
 #include <errno.h>
 #include <math.h>
+#include <sys/syscall.h>
 
 char *proc_stat = "/proc/stat";
 FILE *outf;
@@ -381,11 +382,11 @@ int get_msr_fd(int cpu)
 	return fd;
 }
 
-int get_msr(int cpu, off_t offset, unsigned long long *msr)
+int get_msr(int cpu, unsigned long long offset, unsigned long long *msr)
 {
 	ssize_t retval;
 
-	retval = pread(get_msr_fd(cpu), msr, sizeof(*msr), offset);
+	retval = syscall(SYS_pread64, get_msr_fd(cpu), msr, sizeof(*msr), offset);
 
 	if (retval != sizeof *msr)
 		err(-1, "cpu%d: msr offset 0x%llx read failed", cpu, (unsigned long long)offset);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ