Opened 3 years ago

Closed 3 years ago

#1439 closed defect (fixed)

smartmontools compile fails with "undefined reference to `__stack_chk_guard'"

Reported by: edso Owned by: Christian Franke
Priority: minor Milestone: Release 7.3
Component: all Version: 7.2
Keywords: Cc:


the configure stackprotection detection

might wrongly detect support where there is none.

looks like a change as described here

would prevent that.

thanks!.. ede

Change History (7)

comment:1 by Christian Franke, 3 years ago

Milestone: undecided
Version: 7.2

Smartmontools 7.2 already includes the proposed fix, see r5032.

If this is not effective in your environment this is possibly because the current check does not actually generate calls to __stack_chk_*() functions.

If possible, please test:


    772772    AC_MSG_CHECKING([whether $CXX supports $option])
    773773    save_CXXFLAGS=$CXXFLAGS
    774774    CXXFLAGS="$CXXFLAGS $option"
    775     AC_LINK_IFELSE([AC_LANG_PROGRAM()], [res=yes], [res=no; CXXFLAGS=$save_CXXFLAGS])
     775    AC_LINK_IFELSE([AC_LANG_PROGRAM([[int i;]],
     776      [[volatile char buf[10]; buf[i] = 0;]])],
     777      [res=yes], [res=no; CXXFLAGS=$save_CXXFLAGS])
    776778    AC_MSG_RESULT([$res])
    777779  done

comment:2 by edso, 3 years ago

sorry Christian,

still detects it as working s.b.

user@ubuntu:~/freetz-ng-7360v2$ make smartmontools-precompiled
mkdir -p packages/target-mips_gcc-4.8.5_uClibc-
if test -d make/smartmontools/files; then 	tools/tar-gnu -cf - -C make/smartmontools/files --exclude=.svn --exclude=.git --exclude=.gitignore --exclude=.unpacked --exclude=.configured --exclude=.compiled --exclude=.installed . | tools/tar-gnu -xf - -C packages/target-mips_gcc-4.8.5_uClibc-; fi
---> package/smartmontools ... preparing ... mkdir -p source/target-mips_gcc-4.8.5_uClibc-; tools/gunzip -c dl/smartmontools-7.2.tar.gz | tools/tar-gnu -x -C source/target-mips_gcc-4.8.5_uClibc- --transform='s|^./\+||' --strip-components=1 
set -e; shopt -s nullglob; for i in make/smartmontools/patches/*.patch*; do case $i in *.patch|*.patch.gz|*.patch.bzip2|*.patch.bz2|*|*.patch.xz|*.patch.lz|*.patch.lzma|*.patch.Z) ;; *) continue ;; esac; tools/freetz_patch source/target-mips_gcc-4.8.5_uClibc- $i; done; 
    applying patch file make/smartmontools/patches/test.patch
    patching file
    Hunk #1 succeeded at 766 (offset -6 lines).
configuring ... (conf_cmd() { ./configure  "$@"  || { printf "\n\\033[33m%s\\033[m\n" "ERROR: Build failed.";  exit 1; } }; cd source/target-mips_gcc-4.8.5_uClibc-;  rm -f config.{cache,status};    PATH="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-" FREETZ_LIBRARY_DIR="/usr/lib/freetz" FREETZ_KERNEL_VERSION_MAJOR="3.10" FREETZ_TARGET_ARCH="mips" FREETZ_TARGET_ARCH_ENDIANNESS_DEPENDENT="mips" CC="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-" CXX="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-" CFLAGS="-march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" CXXFLAGS="-march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS="" PKG_CONFIG_PATH="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-" PKG_CONFIG_LIBDIR="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-" GLOBAL_LIBDIR=/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-  CONFIG_SITE=/home/user/freetz-ng-7360v2/include/ conf_cmd   --cache-file=/dev/null --target=mips-linux --host=mips-linux --build=x86_64-pc-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --datadir=/usr/share --includedir=/usr/include --infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man --sbindir=/usr/sbin --sysconfdir=/etc --with-gnu-ld --disable-nls --without-nvme-devicescan   )
configure: WARNING: unrecognized options: --with-gnu-ld, --disable-nls
configure: loading site script /home/user/freetz-ng-7360v2/include/
checking for a BSD-compatible install... /usr/bin/install -c
checking whether os_linux.cpp uses new interface... yes
checking whether /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc- supports -fstack-protector-strong... no
checking whether /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc- supports -fstack-protector... yes
checking whether _FORTIFY_SOURCE is predefined... no
checking whether /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc- supports _FORTIFY_SOURCE=2... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
configure: WARNING: unrecognized options: --with-gnu-ld, --disable-nls
checking whether make sets $(MAKE)... (cached) yes
smartmontools-7.2 configuration:
host operating system:  mips-unknown-linux-gnu
C++ compiler:           /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-
C compiler:             /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-
preprocessor flags:     
C++ compiler flags:     -march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -fstack-protector
C compiler flags:       -march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
linker flags:           
OS specific modules:    os_linux.o cciss.o dev_areca.o  
binary install path:    /usr/sbin
man page install path:  /usr/share/man
doc file install path:  /usr/share/doc/smartmontools
examples install path:  /usr/share/doc/smartmontools/examplescripts
drive database file:    /usr/share/smartmontools/drivedb.h
database update script: /usr/sbin/update-smart-drivedb
database update branch: branches/RELEASE_7_2_DRIVEDB
download tools:         curl wget lynx svn
GnuPG for verification: gpg
local drive database:   /etc/smart_drivedb.h
smartd config file:     /etc/smartd.conf
smartd warning script:  /etc/
smartd plugin path:     /etc/smartd_warning.d
PATH within scripts:    /usr/local/bin:/usr/bin:/bin
smartd initd script:    [disabled]
smartd save files:      [disabled]
smartd attribute logs:  [disabled]
SELinux support:        no
libcap-ng support:      no
systemd notify support: no
NVMe DEVICESCAN:        no

cmd() { PATH="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-" LD_RUN_PATH="/usr/lib/freetz" FREETZ_LIBRARY_DIR="/usr/lib/freetz" make -j16  "$@"  || { printf "\n\\033[33m%s\\033[m\n" "ERROR: Build failed.";  exit 1; } }; 	if [ -e source/.echo_item_start -a ! -e source/.echo_item_build ]; then echo -ne "\e[48;5;56mbuilding\e[49m ... "; touch source/.echo_item_build; fi; cmd -C source/target-mips_gcc-4.8.5_uClibc-
building ... make[1]: Entering directory '/home/user/freetz-ng-7360v2/source/target-mips_gcc-4.8.5_uClibc-'
make  all-am
/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-  -march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -fstack-protector   -o smartd smartd.o atacmdnames.o atacmds.o dev_ata_cmd_set.o dev_intelliprop.o dev_interface.o dev_jmb39x_raid.o knowndrives.o nvmecmds.o scsicmds.o scsiata.o scsinvme.o utility.o     os_linux.o cciss.o dev_areca.o      
smartd.o: In function `vsyslog_lines(int, char const*, void*)':
smartd.cpp:(.text+0x110): undefined reference to `__stack_chk_guard'
smartd.cpp:(.text+0x118): undefined reference to `__stack_chk_guard'
smartd.cpp:(.text+0x1a8): undefined reference to `__stack_chk_guard'
smartd.cpp:(.text+0x1b4): undefined reference to `__stack_chk_fail'
smartd.o: In function `read_ata_error_count(ata_device*, char const*, firmwarebug_defs, bool)':
dev_areca.o: In function `generic_areca_device::arcmsr_scsi_pass_through(scsi_cmnd_io*) [clone .part.6]':
dev_areca.cpp:(.text+0xa68): undefined reference to `__stack_chk_guard'
dev_areca.cpp:(.text+0xa70): undefined reference to `__stack_chk_guard'
dev_areca.cpp:(.text+0xcdc): undefined reference to `__stack_chk_guard'
dev_areca.cpp:(.text+0xce8): undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1039: smartd] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/ataprint.Tpo .deps/ataprint.Po
make[2]: Leaving directory '/home/user/freetz-ng-7360v2/source/target-mips_gcc-4.8.5_uClibc-'
make[1]: *** [Makefile:938: all] Error 2
make[1]: Leaving directory '/home/user/freetz-ng-7360v2/source/target-mips_gcc-4.8.5_uClibc-'

ERROR: Build failed.
make: *** [make/smartmontools/ source/target-mips_gcc-4.8.5_uClibc-] Error 1

comment:3 by Christian Franke, 3 years ago

I don't see any autoconf, autoreconf or ./ in the above protocol. Did you actually rebuild the configure script?

If GNU autotools are not available, please test whether this program could be build manually using the same compiler:

int i;

int main()
  volatile char buf[10];
  buf[i] = 0;
  return 0;

Try with and without -fstack-protector option.

comment:4 by edso, 3 years ago

sorry. not a Make/Autoconf guru myself.

you are right. manually running 'autoreconf' in a patched source dir solves this.

as long as it's unreleased how would you suggest to apply the fix to a buildroot package like the one in Freetz-NG?
i'd assume patching the configure script or?

thx!.. ede

comment:5 by Christian Franke, 3 years ago

Sorry, I'm not familiar with this build system. Various .../make/*/*.mk files there use this:


This possibly runs autoreconf after the patch is applied.

comment:6 by Christian Franke, 3 years ago

Milestone: undecidedRelease 7.3
Owner: set to Christian Franke
Status: newaccepted

comment:7 by Christian Franke, 3 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.