|
Mark Wielaard |
22441b |
commit 3bac39a10abf292d332bb20ab58c6dd5c28f9108
|
|
Mark Wielaard |
22441b |
Author: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
Mark Wielaard |
22441b |
Date: Fri Mar 8 04:07:00 2019 +0100
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
As it turned out, the size of vki_siginfo_t is incorrect on these 64-bit
|
|
Mark Wielaard |
22441b |
architectures:
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
(gdb) p sizeof(vki_siginfo_t)
|
|
Mark Wielaard |
22441b |
$1 = 136
|
|
Mark Wielaard |
22441b |
(gdb) ptype struct vki_siginfo
|
|
Mark Wielaard |
22441b |
type = struct vki_siginfo {
|
|
Mark Wielaard |
22441b |
int si_signo;
|
|
Mark Wielaard |
22441b |
int si_errno;
|
|
Mark Wielaard |
22441b |
int si_code;
|
|
Mark Wielaard |
22441b |
union {
|
|
Mark Wielaard |
22441b |
int _pad[29];
|
|
Mark Wielaard |
22441b |
struct {...} _kill;
|
|
Mark Wielaard |
22441b |
struct {...} _timer;
|
|
Mark Wielaard |
22441b |
struct {...} _rt;
|
|
Mark Wielaard |
22441b |
struct {...} _sigchld;
|
|
Mark Wielaard |
22441b |
struct {...} _sigfault;
|
|
Mark Wielaard |
22441b |
struct {...} _sigpoll;
|
|
Mark Wielaard |
22441b |
} _sifields;
|
|
Mark Wielaard |
22441b |
}
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
It looks like that for this architecture, __VKI_ARCH_SI_PREAMBLE_SIZE
|
|
Mark Wielaard |
22441b |
hasn't been defined properly, which resulted in incorrect
|
|
Mark Wielaard |
22441b |
VKI_SI_PAD_SIZE calculation (29 instead of 28).
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
<6a9e4> DW_AT_name : (indirect string, offset: 0xcf59): _sifields
|
|
Mark Wielaard |
22441b |
<6a9ef> DW_AT_data_member_location: 16
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
This issue has been discovered with strace's "make check-valgrind-memcheck",
|
|
Mark Wielaard |
22441b |
which produced false out-of-bounds writes on ptrace(PTRACE_GETSIGINFO) calls:
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
SYSCALL[24264,1](101) sys_ptrace ( 16898, 24283, 0x0, 0x606bd40 )
|
|
Mark Wielaard |
22441b |
==24264== Syscall param ptrace(getsiginfo) points to unaddressable byte(s)
|
|
Mark Wielaard |
22441b |
==24264== at 0x575C06E: ptrace (ptrace.c:45)
|
|
Mark Wielaard |
22441b |
==24264== by 0x443244: next_event (strace.c:2431)
|
|
Mark Wielaard |
22441b |
==24264== by 0x443D30: main (strace.c:2845)
|
|
Mark Wielaard |
22441b |
==24264== Address 0x606bdc0 is 0 bytes after a block of size 144 alloc'd
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
(Note that the address passed is 0x606bd40 and the address reported is
|
|
Mark Wielaard |
22441b |
0x606bdc0).
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
After the patch, no such errors observed.
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
* include/vki/vki-amd64-linux.h [__x86_64__ && __ILP32__]
|
|
Mark Wielaard |
22441b |
(__vki_kernel_si_clock_t): New typedef.
|
|
Mark Wielaard |
22441b |
[__x86_64__ && __ILP32__] (__VKI_ARCH_SI_CLOCK_T,
|
|
Mark Wielaard |
22441b |
__VKI_ARCH_SI_ATTRIBUTES): New macros.
|
|
Mark Wielaard |
22441b |
[__x86_64__ && !__ILP32__] (__VKI_ARCH_SI_PREAMBLE_SIZE): New macro,
|
|
Mark Wielaard |
22441b |
define to 4 ints.
|
|
Mark Wielaard |
22441b |
* include/vki/vki-arm64-linux.h (__VKI_ARCH_SI_PREAMBLE_SIZE): Likewise.
|
|
Mark Wielaard |
22441b |
* include/vki/vki-ppc64-linux.h [__powerpc64__] (__VKI_ARCH_SI_PREAMBLE_SIZE):
|
|
Mark Wielaard |
22441b |
Likewise.
|
|
Mark Wielaard |
22441b |
* include/vki/vki-linux.h [!__VKI_ARCH_SI_CLOCK_T]
|
|
Mark Wielaard |
22441b |
(__VKI_ARCH_SI_CLOCK_T): New macro, define to vki_clock_t.
|
|
Mark Wielaard |
22441b |
[!__VKI_ARCH_SI_ATTRIBUTES] (__VKI_ARCH_SI_ATTRIBUTES): New macro,
|
|
Mark Wielaard |
22441b |
define to nil.
|
|
Mark Wielaard |
22441b |
(struct vki_siginfo): Use __VKI_ARCH_SI_CLOCK_T type for _utime and
|
|
Mark Wielaard |
22441b |
_stime fields. Add __VKI_ARCH_SI_ATTRIBUTES.
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
Resolves: https://bugs.kde.org/show_bug.cgi?id=405201
|
|
Mark Wielaard |
22441b |
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
|
|
Mark Wielaard |
22441b |
Signed-off-by: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
diff --git a/include/vki/vki-amd64-linux.h b/include/vki/vki-amd64-linux.h
|
|
Mark Wielaard |
22441b |
index d6a5a77e6..fbd353aed 100644
|
|
Mark Wielaard |
22441b |
--- a/include/vki/vki-amd64-linux.h
|
|
Mark Wielaard |
22441b |
+++ b/include/vki/vki-amd64-linux.h
|
|
Mark Wielaard |
22441b |
@@ -297,6 +297,21 @@ struct vki_f_owner_ex {
|
|
Mark Wielaard |
22441b |
#define VKI_RLIMIT_CORE 4 /* max core file size */
|
|
Mark Wielaard |
22441b |
#define VKI_RLIMIT_NOFILE 7 /* max number of open files */
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
+//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
+// From linux-5.0.0/arch/x86/include/uapi/asm/siginfo.h
|
|
Mark Wielaard |
22441b |
+//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
+/* We need that to ensure that sizeof(siginfo) == 128. */
|
|
Mark Wielaard |
22441b |
+#ifdef __x86_64__
|
|
Mark Wielaard |
22441b |
+# ifdef __ILP32__
|
|
Mark Wielaard |
22441b |
+typedef long long __vki_kernel_si_clock_t __attribute__((aligned(4)));
|
|
Mark Wielaard |
22441b |
+# define __VKI_ARCH_SI_CLOCK_T __vki_kernel_si_clock_t
|
|
Mark Wielaard |
22441b |
+# define __VKI_ARCH_SI_ATTRIBUTES __attribute__((aligned(8)))
|
|
Mark Wielaard |
22441b |
+# else
|
|
Mark Wielaard |
22441b |
+# define __VKI_ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
|
|
Mark Wielaard |
22441b |
+# endif
|
|
Mark Wielaard |
22441b |
+#endif
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
// From linux-2.6.9/include/asm-x86_64/socket.h
|
|
Mark Wielaard |
22441b |
//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
diff --git a/include/vki/vki-arm64-linux.h b/include/vki/vki-arm64-linux.h
|
|
Mark Wielaard |
22441b |
index ecea8cc78..69fb3ed00 100644
|
|
Mark Wielaard |
22441b |
--- a/include/vki/vki-arm64-linux.h
|
|
Mark Wielaard |
22441b |
+++ b/include/vki/vki-arm64-linux.h
|
|
Mark Wielaard |
22441b |
@@ -193,6 +193,12 @@ struct vki_sigcontext {
|
|
Mark Wielaard |
22441b |
__vki_u8 __reserved[4096] __attribute__((__aligned__(16)));
|
|
Mark Wielaard |
22441b |
};
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
+//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
+// From linux-5.0.0/arch/arm64/include/uapi/asm/siginfo.h
|
|
Mark Wielaard |
22441b |
+//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
+#define __VKI_ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
// From linux-3.10.5/uapi/include/asm-generic/mman-common.h
|
|
Mark Wielaard |
22441b |
//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h
|
|
Mark Wielaard |
22441b |
index 6024f2165..6903c77db 100644
|
|
Mark Wielaard |
22441b |
--- a/include/vki/vki-linux.h
|
|
Mark Wielaard |
22441b |
+++ b/include/vki/vki-linux.h
|
|
Mark Wielaard |
22441b |
@@ -426,6 +426,14 @@ typedef union vki_sigval {
|
|
Mark Wielaard |
22441b |
#define __VKI_ARCH_SI_BAND_T long
|
|
Mark Wielaard |
22441b |
#endif
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
+#ifndef __VKI_ARCH_SI_CLOCK_T
|
|
Mark Wielaard |
22441b |
+#define __VKI_ARCH_SI_CLOCK_T vki_clock_t
|
|
Mark Wielaard |
22441b |
+#endif
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
+#ifndef __VKI_ARCH_SI_ATTRIBUTES
|
|
Mark Wielaard |
22441b |
+#define __VKI_ARCH_SI_ATTRIBUTES
|
|
Mark Wielaard |
22441b |
+#endif
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
// [[Nb: this type changed between 2.4 and 2.6, but not in a way that
|
|
Mark Wielaard |
22441b |
// affects Valgrind.]]
|
|
Mark Wielaard |
22441b |
typedef struct vki_siginfo {
|
|
Mark Wielaard |
22441b |
@@ -463,8 +471,8 @@ typedef struct vki_siginfo {
|
|
Mark Wielaard |
22441b |
vki_pid_t _pid; /* which child */
|
|
Mark Wielaard |
22441b |
__VKI_ARCH_SI_UID_T _uid; /* sender's uid */
|
|
Mark Wielaard |
22441b |
int _status; /* exit code */
|
|
Mark Wielaard |
22441b |
- vki_clock_t _utime;
|
|
Mark Wielaard |
22441b |
- vki_clock_t _stime;
|
|
Mark Wielaard |
22441b |
+ __VKI_ARCH_SI_CLOCK_T _utime;
|
|
Mark Wielaard |
22441b |
+ __VKI_ARCH_SI_CLOCK_T _stime;
|
|
Mark Wielaard |
22441b |
} _sigchld;
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
|
|
Mark Wielaard |
22441b |
@@ -481,7 +489,7 @@ typedef struct vki_siginfo {
|
|
Mark Wielaard |
22441b |
int _fd;
|
|
Mark Wielaard |
22441b |
} _sigpoll;
|
|
Mark Wielaard |
22441b |
} _sifields;
|
|
Mark Wielaard |
22441b |
-} vki_siginfo_t;
|
|
Mark Wielaard |
22441b |
+} __VKI_ARCH_SI_ATTRIBUTES vki_siginfo_t;
|
|
Mark Wielaard |
22441b |
#endif
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
#define __VKI_SI_FAULT 0
|
|
Mark Wielaard |
22441b |
diff --git a/include/vki/vki-ppc64-linux.h b/include/vki/vki-ppc64-linux.h
|
|
Mark Wielaard |
22441b |
index a5e64dd39..04f72048a 100644
|
|
Mark Wielaard |
22441b |
--- a/include/vki/vki-ppc64-linux.h
|
|
Mark Wielaard |
22441b |
+++ b/include/vki/vki-ppc64-linux.h
|
|
Mark Wielaard |
22441b |
@@ -335,6 +335,14 @@ struct vki_sigcontext {
|
|
Mark Wielaard |
22441b |
long vmx_reserve[VKI_ELF_NVRREG+VKI_ELF_NVRREG+1];
|
|
Mark Wielaard |
22441b |
};
|
|
Mark Wielaard |
22441b |
|
|
Mark Wielaard |
22441b |
+//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
+// From linux-5.0.0/arch/powerpc/include/uapi/asm/siginfo.h
|
|
Mark Wielaard |
22441b |
+//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
+#ifdef __powerpc64__
|
|
Mark Wielaard |
22441b |
+# define __VKI_ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
|
|
Mark Wielaard |
22441b |
+#endif
|
|
Mark Wielaard |
22441b |
+
|
|
Mark Wielaard |
22441b |
//----------------------------------------------------------------------
|
|
Mark Wielaard |
22441b |
// From linux-2.6.13/include/asm-ppc64/mman.h
|
|
Mark Wielaard |
22441b |
//----------------------------------------------------------------------
|