2

I want to compile rippled without source code hardening (specifically, I want to avoid the *_chk functions).

As far as I have been able to determine, gcc/g++ do this hardening with FORTIFY_SOURCE and -fstack-protector, and in order to disable it, either -U_FORTIFY_SOURCE or -D_FORTIFY_SOURCE=0 and -fno-stack-protector should be used.

However, for some reason this is not working for me with rippled. I have modified the SConstruct file so that the above mentioned defines and switches are added, and I see during the build process that they are actually being passed to the compiler and linker. However, when I run readelf -sW rippled | egrep chk, I obtain several lines like:

     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __printf_chk@GLIBC_2.3.4 (2)
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __vfprintf_chk@GLIBC_2.3.4 (2)
    96: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __sprintf_chk@GLIBC_2.3.4 (2)
   100: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __snprintf_chk@GLIBC_2.3.4 (2)
   107: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __fread_chk@GLIBC_2.7 (14)

So I am guessing that the problem is not with the switches and defines. But in that case, what may I be missing? Why are these symbols still being included in the ELF?

PS: I am aware that parenthesizing calls to "_chk"-able functions is an alternative to -U_FORTIFY_SOURCE and -fno-stack-protector, but I am just discarding that option, as I do not want to modify rippled's code (and, however, that would only affect a subset of the functions, as far as I can tell).

Community
  • 1
  • 1
Ginswich
  • 264
  • 3
  • 13
  • It appears that it is related to the fact that I am doing static linking. With dynamic linking, it works correctly (no *_chk symbols are included in the ELF). So I assume that these symbols are "inherited" through some of the statically linked libraries (any way to determine which library is using them?). Probably, building those libraries with -U_FORTIFY_SOURCE and -fno-stack-protector will solve the issue. – Ginswich Jul 06 '16 at 13:29

0 Answers0