Skip to content
Snippets Groups Projects
  • Ilya Verbin's avatar
    e6abe1c9
    cmake: add extra security compiler options · e6abe1c9
    Ilya Verbin authored
    Introduce cmake option ENABLE_HARDENING, which is TRUE by default for
    non-debug regular and static builds, excluding AArch64 and FreeBSD.
    It passess compiler flags that harden Tarantool (including the bundled
    libraries) against memory corruption attacks. The following flags are
    passed:
    
    * -Wformat - Check calls to printf and scanf, etc., to make sure that
      the arguments supplied have types appropriate to the format string
      specified.
    
    * -Wformat-security -Werror=format-security - Warn about uses of format
      functions that represent possible security problems. And make the
      warning into an error.
    
    * -fstack-protector-strong - Emit extra code to check for buffer
      overflows, such as stack smashing attacks.
    
    * -fPIC -pie - Generate position-independent code (PIC). It allows to
      take advantage of the Address Space Layout Randomization (ASLR).
    
    * -z relro -z now - Resolve all dynamically linked functions at the
      beginning of the execution, and then make the GOT read-only.
    
    Also do not disable hardening for Debian and RPM-based Linux distros.
    
    Closes #5372
    Closes #7536
    
    NO_DOC=build
    NO_TEST=build
    e6abe1c9
    History
    cmake: add extra security compiler options
    Ilya Verbin authored
    Introduce cmake option ENABLE_HARDENING, which is TRUE by default for
    non-debug regular and static builds, excluding AArch64 and FreeBSD.
    It passess compiler flags that harden Tarantool (including the bundled
    libraries) against memory corruption attacks. The following flags are
    passed:
    
    * -Wformat - Check calls to printf and scanf, etc., to make sure that
      the arguments supplied have types appropriate to the format string
      specified.
    
    * -Wformat-security -Werror=format-security - Warn about uses of format
      functions that represent possible security problems. And make the
      warning into an error.
    
    * -fstack-protector-strong - Emit extra code to check for buffer
      overflows, such as stack smashing attacks.
    
    * -fPIC -pie - Generate position-independent code (PIC). It allows to
      take advantage of the Address Space Layout Randomization (ASLR).
    
    * -z relro -z now - Resolve all dynamically linked functions at the
      beginning of the execution, and then make the GOT read-only.
    
    Also do not disable hardening for Debian and RPM-based Linux distros.
    
    Closes #5372
    Closes #7536
    
    NO_DOC=build
    NO_TEST=build