public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96191] New: aarch64 stack_protect_test canary leak
@ 2020-07-14  2:49 wilson at gcc dot gnu.org
  2020-07-14  8:22 ` [Bug target/96191] " rsandifo at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: wilson at gcc dot gnu.org @ 2020-07-14  2:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96191

            Bug ID: 96191
           Summary: aarch64 stack_protect_test canary leak
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wilson at gcc dot gnu.org
  Target Milestone: ---

Given a simple testcase
extern int sub (int);

int
main (void)
{
  sub (10);
  return 0;
}
commpiling with -O -S -fstack-protector-all -mstack-protector-guard=global
in the epilogue for the canary check I see
        ldr     x1, [sp, 40]
        ldr     x0, [x19, #:lo12:__stack_chk_guard]
        eor     x0, x1, x0
        cbnz    x0, .L4
Both x0 and x1 have the stack protector canary loaded into them, and the eor
clobbers x0, but x1 is left alone.  This means the value of the canary is
leaking from the epilogue.  The canary value is never supposed to survive in a
register outside the stack protector patterns.

A powerpc64-linux toolchain build with the same testcase and options generates
        lwz 9,28(1)
        lwz 10,0(31)
        xor. 9,9,10
        li 10,0
        bne- 0,.L4
and note that it clears the second register after the xor to prevent the canary
leak.  The aarch64 stack_protect_test pattern should do the same thing.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-11-17 18:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-14  2:49 [Bug target/96191] New: aarch64 stack_protect_test canary leak wilson at gcc dot gnu.org
2020-07-14  8:22 ` [Bug target/96191] " rsandifo at gcc dot gnu.org
2020-07-14 18:58 ` wilco at gcc dot gnu.org
2020-07-14 22:30 ` wilson at gcc dot gnu.org
2020-08-05 14:19 ` cvs-commit at gcc dot gnu.org
2020-08-06 18:20 ` cvs-commit at gcc dot gnu.org
2020-08-07 11:15 ` cvs-commit at gcc dot gnu.org
2020-08-07 11:15 ` cvs-commit at gcc dot gnu.org
2020-08-07 11:18 ` cvs-commit at gcc dot gnu.org
2020-08-07 11:18 ` cvs-commit at gcc dot gnu.org
2020-11-17 18:17 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).