--- msr-tools-1.3.orig/Makefile +++ msr-tools-1.3/Makefile @@ -15,8 +15,8 @@ # CC = gcc -Wall -CFLAGS = -g -O2 -fomit-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -LDFLAGS = +CFLAGS = -g -O2 -fomit-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(shell dpkg-buildflags --get CFLAGS) +LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS) BIN = wrmsr rdmsr cpuid --- msr-tools-1.3.orig/debian/changelog +++ msr-tools-1.3/debian/changelog @@ -0,0 +1,70 @@ +msr-tools (1.3-4) unstable; urgency=low + + * Bump standards-version and debhelper compat, & clean up lintian stuff. + * Specify that root isn't required to build package. + * Github changed their download url, so adjust debian/watch accordingly. + * Enable additional bindnow hardening flags. + + -- Andres Salomon Sat, 04 Dec 2021 21:09:04 +0000 + +msr-tools (1.3-3) unstable; urgency=low + + * Merge fix to check that register is valid (closes: #790075). + * Update package to catch up on 5 years of new debian policy, + standards, debhelper, etc. + * Add a watch file. + + -- Andres Salomon Sun, 02 Dec 2018 07:44:39 +0000 + +msr-tools (1.3-2) unstable; urgency=low + + * Remove cpuid program; there's already a separate cpuid package in + Debian that is more fully-featured. If there's a need to bring back + the cpuid binary, let me know (closes: #726057). + + -- Andres Salomon Tue, 22 Oct 2013 08:25:00 +0000 + +msr-tools (1.3-1) unstable; urgency=low + + * New upstream release (closes: #725930). + * Update the copyright file. + * Update manpages for new args and new cpuid program. + * Update standards-version, and add hardening flags to build. + * Add a note to manpages about ensuring the correct kernel modules + are loaded when running commands (closes: #721825). + + -- Andres Salomon Thu, 10 Oct 2013 23:39:23 +0000 + +msr-tools (1.2-3) unstable; urgency=low + + * Only build for i386 and amd64 (closes: #555542). + + -- Andres Salomon Mon, 23 Nov 2009 05:32:50 +0000 + +msr-tools (1.2-2) unstable; urgency=low + + * Don't allow the package to install anything into /usr/sbin + (closes: #552958, #554583). + * Bump the versioned build-dep on debhelper accordingly, as + override_dh_auto_install is necessary. + + -- Andres Salomon Thu, 05 Nov 2009 18:11:18 +0000 + +msr-tools (1.2-1) unstable; urgency=low + + * New upstream release (for some value of "new"). + * Bump standards version. + * Switch from cdbs to debhelper. It was being too clever in overriding + our CFLAGS, which resulted in 64bit stuff breaking (closes: #495445). + * Update copyright info w/ hpa's mark. + * Drop 001-pwrite_warnings.patch, as it turns out that it was only + necessary due to the aforementioned CFLAGS clobberage. + + -- Andres Salomon Sun, 25 Oct 2009 14:51:24 +0000 + +msr-tools (1.1.2-1) unstable; urgency=low + + * Initial release. + * Create manpages. + + -- Andres Salomon Fri, 07 Mar 2008 12:27:45 +0000 --- msr-tools-1.3.orig/debian/control +++ msr-tools-1.3/debian/control @@ -0,0 +1,17 @@ +Source: msr-tools +Section: admin +Priority: optional +Maintainer: Andres Salomon +Build-Depends: debhelper-compat (= 13) +Standards-Version: 4.6.0.1 +Homepage: https://github.com/01org/msr-tools +Rules-Requires-Root: no + +Package: msr-tools +Architecture: i386 amd64 +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Utilities for modifying MSRs from userspace + MSRs are Machine Specific Registers that are used to set values for + hardware to use, or to pass values between the BIOS and kernel. This + package provides utilities to both read and write MSRs. Reading and + writing MSRs might be useful when debugging kernel drivers, for example. --- msr-tools-1.3.orig/debian/copyright +++ msr-tools-1.3/debian/copyright @@ -0,0 +1,25 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: msr-tools +Source: https://github.com/01org/msr-tools + +Files: * +Copyright: 2000 Transmeta Corporation - All Rights Reserved + 2004-2008 H. Peter Anvin - All Rights Reserved + 2013, Intel Corporation. +License: GPL-2 + This program is free software; you can redistribute it and/or modify + it under the terms and conditions of the GNU General Public License, + version 2, as published by the Free Software Foundation. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Library General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + MA 02110-1301, USA. + . + On Debian systems, the full text of the GPL can be found in + /usr/share/common-licenses/GPL-2 --- msr-tools-1.3.orig/debian/cpuid.1 +++ msr-tools-1.3/debian/cpuid.1 @@ -0,0 +1,27 @@ +.\" +.\" cpuid(1) +.\" +.\" Copyright (C) 2013 Andres Salomon +.TH cpuid 1 "Oct 2013" +.SH NAME +cpuid \- tool for reading CPUIDs from x86 processors +.SH SYNOPSIS +.B "cpuid [processor # (default 0)]" +.SH DESCRIPTION +.B cpuid +is a tool used for reading a processor's CPUID. +.br +Note: if you're running a Debian kernel, be sure that the cpuid.ko kernel +module is loaded. 'modprobe cpuid' should do the trick. Otherwise, you'll +get an error about +.B cpuid +not being able to open files in /dev/cpu/... +.BR +.SH AUTHOR +.br +.B cpuid +was written by Intel + +This man page was contributed by Andres Salomon +for the Debian GNU/Linux system (but may be used by others). + --- msr-tools-1.3.orig/debian/dirs +++ msr-tools-1.3/debian/dirs @@ -0,0 +1 @@ +/usr/sbin --- msr-tools-1.3.orig/debian/manpages +++ msr-tools-1.3/debian/manpages @@ -0,0 +1,2 @@ +debian/rdmsr.1 +debian/wrmsr.1 --- msr-tools-1.3.orig/debian/rdmsr.1 +++ msr-tools-1.3/debian/rdmsr.1 @@ -0,0 +1,73 @@ +.\" +.\" rdmsr(1) +.\" +.\" Copyright (C) 2008 Andres Salomon +.TH rdmsr 1 "Mar 2008" +.SH NAME +rdmsr \- tool for reading CPU machine specific registers (MSR) +.SH SYNOPSIS +.B "rdmsr [options] regno" +.SH DESCRIPTION +.B rdmsr +is a tool used for reading a CPU's machine specific registers (MSR). +.br +Note: if you're running a Debian kernel, be sure that the msr.ko kernel +module is loaded. 'modprobe msr' should do the trick. Otherwise, you'll +get an error about +.B rdmsr +not being able to open files in /dev/cpu/... +.SH OPTIONS +.TP +.B --help, -h +Print a list of available options +.TP +.B --version, -V +Print current version +.TP +.B --hexadecimal, -x +Display output in hexadecimal (lower case) +.TP +.B --capital-hex, -X +Display output in hexadecimal (upper case) +.TP +.B --decimal, -d +Display output in signed decimal +.TP +.B --unsigned, -u +Display output in unsigned decimal +.TP +.B --octal, -o +Display output in octal +.TP +.B --c-language, -c +Format output as a C language constant +.TP +.B --zero-pad, -0 +Output leading zeroes +.TP +.B --zero-pad, -0 +Output leading zeroes +.TP +.B --raw, -r +Output raw binary +.TP +.B --all, -a +All processors +.TP +.B --processor <#>, -p +Select processor number (default: 0) +.TP +.B --bitfield h:l, -f +Output bits [h:l] only +.TP +.BR +.SH SEE ALSO +.BR wrmsr(1) +.SH AUTHOR +.br +.B rdmsr +was written by Transmeta Corporation + +This man page was contributed by Andres Salomon +for the Debian GNU/Linux system (but may be used by others). + --- msr-tools-1.3.orig/debian/register-parse.patch +++ msr-tools-1.3/debian/register-parse.patch @@ -0,0 +1,51 @@ +commit eedf406a48e8354f680df19abb0784d9cd3ac1c5 +Author: Yazen Ghannam +Date: Mon Sep 17 11:57:04 2018 -0500 + + Fail to read/write if register number is not parsed correctly + + It's possible that a user will provide a register number in a format + that strtoul() can't parse. strtoul() will return 0 if it fails to parse + a value. The msr-tools will then silently read/write to MSR 0x0 and + succeed. At best this may confuse the user, or at worst this will + unintentionally write bad data to the system. + + Check that the register number parsing has succeeded. If it fails, then + inform the user, give a suggestion, and exit. + + Signed-off-by: Yazen Ghannam + +diff --git a/rdmsr.c b/rdmsr.c +index b19986a..48e70a3 100644 +--- a/rdmsr.c ++++ b/rdmsr.c +@@ -194,7 +194,11 @@ int main(int argc, char *argv[]) + exit(127); + } + +- reg = strtoul(argv[optind], NULL, 0); ++ reg = strtoul(argv[optind], &endarg, 0); ++ if (*endarg) { ++ printf("Failed to parse register number.\n"); ++ exit(127); ++ } + + if (cpu == -1) { + doing_for_all = 1; +diff --git a/wrmsr.c b/wrmsr.c +index b32cc3e..0128153 100644 +--- a/wrmsr.c ++++ b/wrmsr.c +@@ -121,7 +121,11 @@ int main(int argc, char *argv[]) + exit(127); + } + +- reg = strtoul(argv[optind++], NULL, 0); ++ reg = strtoul(argv[optind++], &endarg, 0); ++ if (*endarg) { ++ printf("Failed to parse register number.\n"); ++ exit(127); ++ } + + if (cpu == -1) { + doing_for_all = 1; --- msr-tools-1.3.orig/debian/rules +++ msr-tools-1.3/debian/rules @@ -0,0 +1,12 @@ +#!/usr/bin/make -f + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/buildflags.mk + +%: + dh $@ + +override_dh_auto_install: + make install sbindir=debian/msr-tools/usr/sbin + rm -f debian/msr-tools/usr/sbin/cpuid --- msr-tools-1.3.orig/debian/source/format +++ msr-tools-1.3/debian/source/format @@ -0,0 +1 @@ +1.0 --- msr-tools-1.3.orig/debian/watch +++ msr-tools-1.3/debian/watch @@ -0,0 +1,3 @@ +version=4 +opts=dversionmangle=auto \ +https://github.com/01org/msr-tools/tags .*/msr-tools-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) --- msr-tools-1.3.orig/debian/wrmsr.1 +++ msr-tools-1.3/debian/wrmsr.1 @@ -0,0 +1,43 @@ +.\" +.\" wrmsr(1) +.\" +.\" Copyright (C) 2008 Andres Salomon +.TH wrmsr 1 "Mar 2008" +.SH NAME +wrmsr \- tool for writing CPU machine specific registers (MSR) +.SH SYNOPSIS +.B "wrmsr [options] regno value" +.SH DESCRIPTION +.B wrmsr +is a tool used for writing values to a CPU's machine specific registers (MSR). +.br +Note: if you're running a Debian kernel, be sure that the msr.ko kernel +module is loaded. 'modprobe msr' should do the trick. Otherwise, you'll +get an error about +.B wrmsr +not being able to open files in /dev/cpu/... +.SH OPTIONS +.TP +.B --help, -h +Print a list of available options +.TP +.B --version, -V +Print current version +.TP +.B --all, -a +All processors +.TP +.B --processor <#>, -p +Select processor number (default: 0) +.TP +.BR +.SH SEE ALSO +.BR rdmsr(1) +.SH AUTHOR +.br +.B wrmsr +was written by Transmeta Corporation + +This man page was contributed by Andres Salomon +for the Debian GNU/Linux system (but may be used by others). + --- msr-tools-1.3.orig/rdmsr.c +++ msr-tools-1.3/rdmsr.c @@ -193,7 +193,11 @@ exit(127); } - reg = strtoul(argv[optind], NULL, 0); + reg = strtoul(argv[optind], &endarg, 0); + if (*endarg) { + printf("Failed to parse register number.\n"); + exit(127); + } if (cpu == -1) { rdmsr_on_all_cpus(reg); --- msr-tools-1.3.orig/wrmsr.c +++ msr-tools-1.3/wrmsr.c @@ -120,7 +120,11 @@ exit(127); } - reg = strtoul(argv[optind++], NULL, 0); + reg = strtoul(argv[optind++], &endarg, 0); + if (*endarg) { + printf("Failed to parse register number.\n"); + exit(127); + } if (cpu == -1) { wrmsr_on_all_cpus(reg, argc - optind, &argv[optind]);