fix #671135 - peekfd utility doesn't work on ppc64 architecture

This commit is contained in:
Jan Görig 2011-01-27 10:36:06 +01:00
parent 055dabaf4f
commit 4bf1daf08c
2 changed files with 59 additions and 1 deletions

53
psmisc-22.13-ppc64.patch Normal file
View File

@ -0,0 +1,53 @@
diff --git a/src/peekfd.c b/src/peekfd.c
index 6d759b9..c4a3474 100644
--- a/src/peekfd.c
+++ b/src/peekfd.c
@@ -55,6 +55,9 @@
#define REG_PARAM1 orig_gpr3
#define REG_PARAM2 gpr[4]
#define REG_PARAM3 gpr[5]
+#ifndef PT_ORIG_R3
+ #define PT_ORIG_R3 34
+#endif
#elif defined(ARM)
#ifndef __ARM_EABI__
#error arm oabi not supported
@@ -73,9 +76,6 @@
#define REG_PARAM1 regs[4]
#define REG_PARAM2 regs[5]
#define REG_PARAM3 regs[6]
-#ifndef PT_ORIG_R3
- #define PT_ORIG_R3 34
-#endif
#endif
#define MAX_ATTACHED_PIDS 1024
@@ -222,11 +222,11 @@ int main(int argc, char **argv)
if (WIFSTOPPED(status)) {
#ifdef PPC
struct pt_regs regs;
- regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, 4 * PT_R0, 0);
- regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, 4 * PT_R3, 0);
- regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, 4 * PT_R4, 0);
- regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, 4 * PT_R5, 0);
- regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, 4 * PT_ORIG_R3, 0);
+ regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R0, 0);
+ regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R3, 0);
+ regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R4, 0);
+ regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R5, 0);
+ regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_ORIG_R3, 0);
#elif defined(ARM)
struct pt_regs regs;
ptrace(PTRACE_GETREGS, pid, 0, &regs);
@@ -271,7 +271,11 @@ int main(int argc, char **argv)
for (i = 0; i < regs.REG_PARAM3; i++) {
#ifdef _BIG_ENDIAN
+#if __WORDSIZE == 64
+ unsigned int a = bswap_64(ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + i, 0));
+#else
unsigned int a = bswap_32(ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + i, 0));
+#endif
#else
unsigned int a = ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + i, 0);
#endif

View File

@ -1,7 +1,7 @@
Summary: Utilities for managing processes on your system
Name: psmisc
Version: 22.13
Release: 6%{?dist}
Release: 7%{?dist}
License: GPLv2+
Group: Applications/System
Source: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
@ -16,6 +16,7 @@ BuildRequires: autoconf automake
Patch1: psmisc-22.13-peekfd-segv.patch
Patch2: psmisc-22.13-fuser-silent.patch
Patch3: psmisc-22.13-killall-pgid.patch
Patch4: psmisc-22.13-ppc64.patch
%description
The psmisc package contains utilities for managing processes on your
@ -31,6 +32,7 @@ of processes that are using specified files or filesystems.
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build
%configure --prefix=%{_prefix} --enable-selinux
@ -65,6 +67,9 @@ rm -rf $RPM_BUILD_ROOT
%doc AUTHORS ChangeLog COPYING README
%changelog
* Thu Jan 27 2011 Jan Görig <jgorig@redhat.com> 22.13-7
- fix #671135 - peekfd utility doesn't work on ppc64 architecture
* Fri Jan 7 2011 Jan Görig <jgorig@redhat.com> 22.13-6
- fix #666213 - uninitialized memory leading to `killall -g name` failure