]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
sigframe construction for x86-linux: ensure that ESP is correctly aligned before...
authorJulian Seward <jseward@acm.org>
Wed, 3 Oct 2018 13:29:42 +0000 (15:29 +0200)
committerJulian Seward <jseward@acm.org>
Wed, 3 Oct 2018 13:29:42 +0000 (15:29 +0200)
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.

coregrind/m_sigframe/sigframe-x86-linux.c

index 27ca4c2aa00cc6c4d4cc204aad63ad0fa4df2f48..63bcf196e03af36704ca923c2bbb5ce9ffd0b229 100644 (file)
@@ -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))