]> git.ipfire.org Git - thirdparty/valgrind.git/commit
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 8 Mar 2019 03:07:00 +0000 (04:07 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 19 Sep 2019 22:16:00 +0000 (00:16 +0200)
commit3bac39a10abf292d332bb20ab58c6dd5c28f9108
treef5df995beedfcdc8680fb6ed9bf416f7f5b03aa9
parent53cceb2ac2c8f92e875b06c2017e707295e3e96b
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64

As it turned out, the size of vki_siginfo_t is incorrect on these 64-bit
architectures:

    (gdb) p sizeof(vki_siginfo_t)
    $1 = 136
    (gdb) ptype struct vki_siginfo
    type = struct vki_siginfo {
        int si_signo;
        int si_errno;
        int si_code;
        union {
            int _pad[29];
            struct {...} _kill;
            struct {...} _timer;
            struct {...} _rt;
            struct {...} _sigchld;
            struct {...} _sigfault;
            struct {...} _sigpoll;
        } _sifields;
    }

It looks like that for this architecture, __VKI_ARCH_SI_PREAMBLE_SIZE
hasn't been defined properly, which resulted in incorrect
VKI_SI_PAD_SIZE calculation (29 instead of 28).

    <6a9e4>   DW_AT_name        : (indirect string, offset: 0xcf59): _sifields
    <6a9ef>   DW_AT_data_member_location: 16

This issue has been discovered with strace's "make check-valgrind-memcheck",
which produced false out-of-bounds writes on ptrace(PTRACE_GETSIGINFO) calls:

    SYSCALL[24264,1](101) sys_ptrace ( 16898, 24283, 0x0, 0x606bd40 )
    ==24264== Syscall param ptrace(getsiginfo) points to unaddressable byte(s)
    ==24264==    at 0x575C06E: ptrace (ptrace.c:45)
    ==24264==    by 0x443244: next_event (strace.c:2431)
    ==24264==    by 0x443D30: main (strace.c:2845)
    ==24264==  Address 0x606bdc0 is 0 bytes after a block of size 144 alloc'd

(Note that the address passed is 0x606bd40 and the address reported is
0x606bdc0).

After the patch, no such errors observed.

* include/vki/vki-amd64-linux.h [__x86_64__ && __ILP32__]
(__vki_kernel_si_clock_t): New typedef.
[__x86_64__ && __ILP32__] (__VKI_ARCH_SI_CLOCK_T,
__VKI_ARCH_SI_ATTRIBUTES): New macros.
[__x86_64__ && !__ILP32__] (__VKI_ARCH_SI_PREAMBLE_SIZE): New macro,
define to 4 ints.
* include/vki/vki-arm64-linux.h (__VKI_ARCH_SI_PREAMBLE_SIZE): Likewise.
* include/vki/vki-ppc64-linux.h [__powerpc64__] (__VKI_ARCH_SI_PREAMBLE_SIZE):
Likewise.
* include/vki/vki-linux.h [!__VKI_ARCH_SI_CLOCK_T]
(__VKI_ARCH_SI_CLOCK_T): New macro, define to vki_clock_t.
[!__VKI_ARCH_SI_ATTRIBUTES] (__VKI_ARCH_SI_ATTRIBUTES): New macro,
define to nil.
(struct vki_siginfo): Use __VKI_ARCH_SI_CLOCK_T type for _utime and
_stime fields.  Add __VKI_ARCH_SI_ATTRIBUTES.

Resolves: https://bugs.kde.org/show_bug.cgi?id=405201
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Eugene Syromyatnikov <evgsyr@gmail.com>
NEWS
include/vki/vki-amd64-linux.h
include/vki/vki-arm64-linux.h
include/vki/vki-linux.h
include/vki/vki-ppc64-linux.h