Skip to content

Does not build on gentoo hardened with hardened kernel sources #74

Open

Description

@konstantinblaesi
date=Fri Jan  3 16:24:05 GMT 2014
release=dtrace-20140103
build=466
/dtrace4linux/linux
Sun Mar  9 12:32:35 CET 2014
$ uname -a:
Linux zfs-server 3.12.8-hardened-r1 #1 SMP Sat Mar 1 02:22:38 CET 2014 x86_64 Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz GenuineIntel GNU/Linux
$ cat /etc/os-release
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo/Linux"
ANSI_COLOR="1;32"
HOME_URL="http://www.gentoo.org/"
SUPPORT_URL="http://www.gentoo.org/main/en/support.xml"
BUG_REPORT_URL="https://bugs.gentoo.org/"
$ cat /etc/motd
cat: /etc/motd: No such file or directory
$ cat build/port.h
/* This file is automatically generated via mkport.pl */
/* kern=/lib/modules/3.12.8-hardened-r1/build */
/* kern_src=/lib/modules/3.12.8-hardened-r1/source */

# define DO_NOT_HAVE_ZLIB_IN_KERNEL 1
# define FUNC_DUMP_TRACE_ARGS 6
# define HAVE_ATOMIC_NOTIFIER_CHAIN_REGISTER 1
# define HAVE_BX_REGISTER 1
# define HAVE_CPLUS_DEMANGLE 1
# define HAVE_DWARF_H_ENUM 1
# define HAVE_ELF_C_READ_MMAP 1
# define HAVE_ELF_GETSHDRSTRNDX 1
# define HAVE_INCLUDE_LINUX_CRED_H 1
# define HAVE_INCLUDE_LINUX_HRTIMER_H 1
# define HAVE_INCLUDE_LINUX_KDEBUG_H 1
# define HAVE_INCLUDE_LINUX_MUTEX_H 1
# define HAVE_INCLUDE_LINUX_SEMAPHORE_H 1
# define HAVE_INCLUDE_LINUX_SLAB_H 1
# define HAVE_LEX_YYTEXT_PTR 1
# define HAVE_LIB_LIBDW 1
# define HAVE_LINUX_FDTABLE_H 1
# define HAVE_LINUX_MIGRATE_H 1
# define HAVE_STACKTRACE_OPS 
# define HAVE_VMALLOC_SYNC_ALL 1
# define SMP_CALL_FUNCTION_ARGS 3
# define SMP_CALL_FUNCTION_SINGLE_ARGS 4
$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.2/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.8.2-r1/work/gcc-4.8.2/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.2 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.2/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.2/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/include/g++-v4 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.2/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.8.2-r1 p1.4-ssptest, pie-0.5.9-ssptest' --enable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --with-multilib-list=m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libquadmath --enable-lto --without-cloog
Thread model: posix
gcc version 4.8.2 (Gentoo Hardened 4.8.2-r1 p1.4-ssptest, pie-0.5.9-ssptest) 
$ ld -v
GNU ld (GNU Binutils) 2.23.2
flex 2.5.37
bison (GNU Bison) 2.4.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
processor   : 0
processor   : 1
processor   : 2
processor   : 3
processor   : 4
processor   : 5
processor   : 6
processor   : 7
model       : 58
model name  : Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz
=========================
make[1]: warning: jobserver unavailable: using -j1.  Add `+' to parent make rule.
BUILD_DIR=build-3.12.8-hardened-r1 tools/build.pl build-3.12.8-hardened-r1 `uname -m`
tools/check_dep.pl
tools/mkport.pl
tools/libgcc.pl
tools/mksyscall.pl
Processing (32): /usr/include/asm/unistd_32.h
Creating: build-3.12.8-hardened-r1/driver/syscalls-x86.tbl - 347 entries
Processing (64): /usr/include/asm/unistd_64.h
Creating: build-3.12.8-hardened-r1/driver/syscalls-x86-64.tbl - 314 entries
make all0
cd tests ; make --no-print-directory
case `uname -m` in \
  x86_64) \
    cc -m64 -g -o ../build-3.12.8-hardened-r1/sys64 syscalls.c ; \
    cc -m32 -g -o ../build-3.12.8-hardened-r1/sys32 syscalls.c || true ; \
    ;; \
  i686) \
    cc -m32 -g -o ../build-3.12.8-hardened-r1/sys32 syscalls.c ; \
    ;; \
  arm*) \
    cc -g -o ../build-3.12.8-hardened-r1/sys32 syscalls.c ; \
    ;; \
esac
In file included from /usr/include/features.h:400:0,
                 from /usr/include/stdio.h:27,
                 from syscalls.c:7:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
 # include <gnu/stubs-32.h>
                           ^
compilation terminated.
cd libctf ; make --no-print-directory
cd libdtrace ; make --no-print-directory
cd liblinux ; make --no-print-directory
cd libproc/common ; make --no-print-directory
cd librtld ; make --no-print-directory
cd cmd/dtrace ; make --no-print-directory
cd cmd/ctfconvert ; make --no-print-directory
=================================================================
=== You need /usr/lib/libdwarf.a or /usr/lib64/libdwarf.a 
=== (libdw is not yet supported) to build.
=== 
=== apt-get install binutils-dev
=== apt-get install libdw-dev
=== 
=== Without these, we will not build ctfconvert (needed for 
=== SDT structure definitions).
=================================================================
cd cmd/instr ; make --no-print-directory
cd usdt/c ; make --no-print-directory
tools/mkdriver.pl all
Executing: /dtrace4linux/linux/tools/make-me
make -C /lib/modules/3.12.8-hardened-r1/build M=/dtrace4linux/linux/build-3.12.8-hardened-r1/driver
  CC [M]  /dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.o
/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c: In function ‘fbt_provide_module’:
�[31m�[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:580:9: error: �[m‘struct module’ has no member named ‘module_init’
   if (mp->module_init && mp->init_size &&
         ^
�[31m�[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:580:28: error: �[m‘struct module’ has no member named ‘init_size’
   if (mp->module_init && mp->init_size &&
                            ^
�[31m�[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:581:30: error: �[m‘struct module’ has no member named ‘module_init’
       instr >= (uint8_t *) mp->module_init && 
                              ^
�[31m�[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:582:29: error: �[m‘struct module’ has no member named ‘module_init’
       instr < (uint8_t *) mp->module_init + mp->init_size) {
                             ^
�[31m�[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:582:47: error: �[m‘struct module’ has no member named ‘init_size’
       instr < (uint8_t *) mp->module_init + mp->init_size) {
                                               ^
make[4]: *** [/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.o] Error 1
make[3]: *** [_module_/dtrace4linux/linux/build-3.12.8-hardened-r1/driver] Error 2
make[2]: *** [kernel] Error 2
tools/bug.sh
make[1]: *** [all] Error 1

Activity

  1. dtrace4linux commented on Mar 9, 2014

    @dtrace4linux
    Owner

    I suspect this is more of a 3.12 kernel issue than the hardening issue
    (unless you can suggest otherwise).

    I will take a look in a while (probably just before or after the next
    Ubuntu release).

    thanks

    On 9 March 2014 20:09, elxa notifications@github.com wrote:

    date=Fri Jan 3 16:24:05 GMT 2014
    release=dtrace-20140103
    build=466
    /dtrace4linux/linux
    Sun Mar 9 12:32:35 CET 2014
    $ uname -a:
    Linux zfs-server 3.12.8-hardened-r1 #1 SMP Sat Mar 1 02:22:38 CET 2014 x86_64 Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz GenuineIntel GNU/Linux
    $ cat /etc/os-release
    NAME=Gentoo
    ID=gentoo
    PRETTY_NAME="Gentoo/Linux"
    ANSI_COLOR="1;32"
    HOME_URL="http://www.gentoo.org/"
    SUPPORT_URL="http://www.gentoo.org/main/en/support.xml"
    BUG_REPORT_URL="https://bugs.gentoo.org/"
    $ cat /etc/motd
    cat: /etc/motd: No such file or directory
    $ cat build/port.h
    /* This file is automatically generated via mkport.pl /
    /
    kern=/lib/modules/3.12.8-hardened-r1/build /
    /
    kern_src=/lib/modules/3.12.8-hardened-r1/source */

    define DO_NOT_HAVE_ZLIB_IN_KERNEL 1

    define FUNC_DUMP_TRACE_ARGS 6

    define HAVE_ATOMIC_NOTIFIER_CHAIN_REGISTER 1

    define HAVE_BX_REGISTER 1

    define HAVE_CPLUS_DEMANGLE 1

    define HAVE_DWARF_H_ENUM 1

    define HAVE_ELF_C_READ_MMAP 1

    define HAVE_ELF_GETSHDRSTRNDX 1

    define HAVE_INCLUDE_LINUX_CRED_H 1

    define HAVE_INCLUDE_LINUX_HRTIMER_H 1

    define HAVE_INCLUDE_LINUX_KDEBUG_H 1

    define HAVE_INCLUDE_LINUX_MUTEX_H 1

    define HAVE_INCLUDE_LINUX_SEMAPHORE_H 1

    define HAVE_INCLUDE_LINUX_SLAB_H 1

    define HAVE_LEX_YYTEXT_PTR 1

    define HAVE_LIB_LIBDW 1

    define HAVE_LINUX_FDTABLE_H 1

    define HAVE_LINUX_MIGRATE_H 1

    define HAVE_STACKTRACE_OPS

    define HAVE_VMALLOC_SYNC_ALL 1

    define SMP_CALL_FUNCTION_ARGS 3

    define SMP_CALL_FUNCTION_SINGLE_ARGS 4

    $ gcc -v
    Using built-in specs.
    COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.2/gcc
    COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.2/lto-wrapper
    Target: x86_64-pc-linux-gnu
    Configured with: /var/tmp/portage/sys-devel/gcc-4.8.2-r1/work/gcc-4.8.2/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.2 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.2/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.2/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/include/g++-v4 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.2/python --enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.8.2-r1 p1.4-ssptest, pie-0.5.9-ssptest' --enable-esp --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --with-multilib-list=m64 --disable-altivec --disable-fixed-point --enable-targets=all --disable-libgcj --enable-libgomp --disable-libmudflap --disable-libssp --disable-libquadmath --enable-lto --without-cloog
    Thread model: posix
    gcc version 4.8.2 (Gentoo Hardened 4.8.2-r1 p1.4-ssptest, pie-0.5.9-ssptest)
    $ ld -v
    GNU ld (GNU Binutils) 2.23.2
    flex 2.5.37
    bison (GNU Bison) 2.4.3
    Written by Robert Corbett and Richard Stallman.

    Copyright (C) 2010 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    processor : 0
    processor : 1
    processor : 2
    processor : 3
    processor : 4
    processor : 5
    processor : 6
    processor : 7
    model : 58

    model name : Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz

    make[1]: warning: jobserver unavailable: using -j1. Add +' to parent make rule. BUILD_DIR=build-3.12.8-hardened-r1 tools/build.pl build-3.12.8-hardened-r1uname -m tools/check_dep.pl tools/mkport.pl tools/libgcc.pl tools/mksyscall.pl Processing (32): /usr/include/asm/unistd_32.h Creating: build-3.12.8-hardened-r1/driver/syscalls-x86.tbl - 347 entries Processing (64): /usr/include/asm/unistd_64.h Creating: build-3.12.8-hardened-r1/driver/syscalls-x86-64.tbl - 314 entries make all0 cd tests ; make --no-print-directory caseuname -m` in
    x86_64)
    cc -m64 -g -o ../build-3.12.8-hardened-r1/sys64 syscalls.c ;
    cc -m32 -g -o ../build-3.12.8-hardened-r1/sys32 syscalls.c || true ;
    ;;
    i686)
    cc -m32 -g -o ../build-3.12.8-hardened-r1/sys32 syscalls.c ;
    ;;
    arm*)
    cc -g -o ../build-3.12.8-hardened-r1/sys32 syscalls.c ;
    ;;
    esac
    In file included from /usr/include/features.h:400:0,
    from /usr/include/stdio.h:27,
    from syscalls.c:7:
    /usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory

    include <gnu/stubs-32.h>

                           ^
    

    compilation terminated.
    cd libctf ; make --no-print-directory
    cd libdtrace ; make --no-print-directory
    cd liblinux ; make --no-print-directory
    cd libproc/common ; make --no-print-directory
    cd librtld ; make --no-print-directory
    cd cmd/dtrace ; make --no-print-directory

    cd cmd/ctfconvert ; make --no-print-directory

    === You need /usr/lib/libdwarf.a or /usr/lib64/libdwarf.a

    === (libdw is not yet supported) to build.

    === apt-get install binutils-dev

    === apt-get install libdw-dev

    === Without these, we will not build ctfconvert (needed for

    === SDT structure definitions).

    cd cmd/instr ; make --no-print-directory
    cd usdt/c ; make --no-print-directory
    tools/mkdriver.pl all
    Executing: /dtrace4linux/linux/tools/make-me
    make -C /lib/modules/3.12.8-hardened-r1/build M=/dtrace4linux/linux/build-3.12.8-hardened-r1/driver
    CC [M] /dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.o
    /dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c: In function 'fbt_provide_module':
    [31m[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:580:9: error: [m'struct module' has no member named 'module_init'
    if (mp->module_init && mp->init_size &&
    ^
    [31m[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:580:28: error: [m'struct module' has no member named 'init_size'
    if (mp->module_init && mp->init_size &&
    ^
    [31m[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:581:30: error: [m'struct module' has no member named 'module_init'
    instr >= (uint8_t ) mp->module_init &&
    ^
    [31m[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:582:29: error: [m'struct module' has no member named 'module_init'
    instr < (uint8_t *) mp->module_init + mp->init_size) {
    ^
    [31m[1m/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.c:582:47: error: [m'struct module' has no member named 'init_size'
    instr < (uint8_t *) mp->module_init + mp->init_size) {
    ^
    make[4]: *
    * [/dtrace4linux/linux/build-3.12.8-hardened-r1/driver/fbt_linux.o] Error 1
    make[3]: *** [module/dtrace4linux/linux/build-3.12.8-hardened-r1/driver] Error 2
    make[2]: *** [kernel] Error 2
    tools/bug.sh
    make[1]: *** [all] Error 1

    Reply to this email directly or view it on GitHubhttps://github.com//issues/74
    .

  2. solaris-ventus commented on Apr 28, 2016

    @solaris-ventus

    This is a problem with the patch grsecurity.
    Archive with the patch applied to the hardened-sources kernel is:
    http://dev.gentoo.org/~blueness/hardened-sources/hardened-patches/

    Part of the patch (For kernel 4.4.2):

    @@ -370,20 +373,21 @@ struct module {
    * If this is non-NULL, vfree() after init() returns.
         *
         * Cacheline align here, such that:
    -    *   module_init, module_core, init_size, core_size,
    +    *   module_init_*, module_core_*, init_size_*, core_size_*,
         *   init_text_size, core_text_size and mtn_core::{mod,node[0]}
         * are on the same cacheline.
         */
    -   void *module_init   ____cacheline_aligned;
    +   void *module_init_rw    ____cacheline_aligned;
    +   void *module_init_rx;
    
        /* Here is the actual code + data, vfree'd on unload. */
    -   void *module_core;
    +   void *module_core_rx, *module_core_rw;
    
        /* Here are the sizes of the init and core sections */
    -   unsigned int init_size, core_size;
    +   unsigned int init_size_rw, core_size_rw;
    
        /* The size of the executable code in each section.  */
    -   unsigned int init_text_size, core_text_size;
    +   unsigned int init_size_rx, core_size_rx;
    
     #ifdef CONFIG_MODULES_TREE_LOOKUP
        /*
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions