From: Julian Seward Date: Wed, 3 Oct 2018 13:29:42 +0000 (+0200) Subject: sigframe construction for x86-linux: ensure that ESP is correctly aligned before... X-Git-Tag: VALGRIND_3_14_0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e214c4858a6fdd5697e767543a0c19e30505582;p=thirdparty%2Fvalgrind.git sigframe construction for x86-linux: ensure that ESP is correctly aligned before entering the handler. n-i-bz. Without this, a signal handler compiled by Clang 6, which uses movdqa to load/store relative to ESP, segfaults because the resulting address isn't 16-aligned. --- diff --git a/coregrind/m_sigframe/sigframe-x86-linux.c b/coregrind/m_sigframe/sigframe-x86-linux.c index 27ca4c2aa0..63bcf196e0 100644 --- a/coregrind/m_sigframe/sigframe-x86-linux.c +++ b/coregrind/m_sigframe/sigframe-x86-linux.c @@ -430,7 +430,7 @@ static Addr build_sigframe(ThreadState *tst, vg_assert((flags & VKI_SA_SIGINFO) == 0); esp -= sizeof(*frame); - esp = VG_ROUNDDN(esp, 16); + esp = VG_ROUNDDN(esp, 16) - 4; frame = (struct sigframe *)esp; if (! ML_(sf_maybe_extend_stack)(tst, esp, sizeof(*frame), flags)) @@ -487,7 +487,7 @@ static Addr build_rt_sigframe(ThreadState *tst, vg_assert((flags & VKI_SA_SIGINFO) != 0); esp -= sizeof(*frame); - esp = VG_ROUNDDN(esp, 16); + esp = VG_ROUNDDN(esp, 16) - 4; frame = (struct rt_sigframe *)esp; if (! ML_(sf_maybe_extend_stack)(tst, esp, sizeof(*frame), flags))