Bug 405201 - Incorrect size of struct vki_siginfo on 64-bit Linux architectures
Summary: Incorrect size of struct vki_siginfo on 64-bit Linux architectures
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Mark Wielaard
URL: https://sourceforge.net/p/valgrind/ma...
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-08 02:46 UTC by Dmitry V. Levin
Modified: 2020-01-29 22:39 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64 (3.21 KB, text/plain)
2019-09-17 03:14 UTC, Mark Wielaard
Details
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64 (7.13 KB, text/plain)
2019-09-19 22:18 UTC, Mark Wielaard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry V. Levin 2019-03-08 02:46:23 UTC
strace's "make check-valgind-memcheck" produces false reports about out-of-bounds writes on ptrace(PTRACE_GETSIGINFO) invocations on x86_64.

This turned out to be a bug in the definition of struct vki_siginfo: its size is 136 which exceeds VKI_SI_MAX_SIZE==128 by 8 bytes.

As all 64-bit architectures have union _sifields aligned to wordsize
boundary, there is a hole between the preamble and _sifields.

Unfortunately, __VKI_ARCH_SI_PREAMBLE_SIZE doesn't take this into account,
this results to off-by-one bug in VKI_SI_PAD_SIZE and the whole structure being 8 bytes larger on 64-bit architectures.
Comment 1 Julian Seward 2019-03-10 10:07:29 UTC
Do you have a patch to fix this?
Comment 2 Dmitry V. Levin 2019-03-10 14:14:13 UTC
(In reply to Julian Seward from comment #1)
> Do you have a patch to fix this?

https://sourceforge.net/p/valgrind/mailman/message/36606811/

Besides that, Eugene is working on a test for this bug.
Comment 3 Mark Wielaard 2019-09-17 03:14:50 UTC
Created attachment 122687 [details]
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64

Patch from the mailinglist
Comment 4 Mark Wielaard 2019-09-19 22:18:08 UTC
Created attachment 122744 [details]
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64

Thanks. I pushed the commit as attached.
Checked that running make check-valgrind-memcheck doesn't show any issues anymore (at least no ptrace related).

commit 3bac39a10abf292d332bb20ab58c6dd5c28f9108
Comment 5 Mark Wielaard 2020-01-29 22:39:13 UTC
Not that this patch caused bug #416760