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

            Bug ID: 68680
           Summary: On-stack VLA does not cause instrumentation with
                    -fstack-protector-strong
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fw at gcc dot gnu.org
  Target Milestone: ---
            Target: x864_64-redhat-linux-gnu

This test case

int process(char *);

int
uses_vla(unsigned long sz)
{
  char buf[sz];
  return process(buf);
}

compiles to:

uses_vla:
        pushq   %rbp
        addq    $15, %rdi
        andq    $-16, %rdi
        movq    %rsp, %rbp
        subq    %rdi, %rsp
        movq    %rsp, %rdi
        call    process
        leave
        ret

This happens with the C and C++ compilers.

The process function may have a buffer overflow, so stack protector
instrumentation is required here.

The equivalent test case with alloca passes.

Reply via email to