Skip to content
Snippets Groups Projects
  1. Jul 10, 2019
  2. Jul 09, 2019
    • Masahiro Yamada's avatar
      kbuild: compile-test kernel headers to ensure they are self-contained · 43c78d88
      Masahiro Yamada authored
      
      The headers in include/ are globally used in the kernel source tree
      to provide common APIs. They are included from external modules, too.
      
      It will be useful to make as many headers self-contained as possible
      so that we do not have to rely on a specific include order.
      
      There are more than 4000 headers in include/. In my rough analysis,
      70% of them are already self-contained. With efforts, most of them
      can be self-contained.
      
      For now, we must exclude more than 1000 headers just because they
      cannot be compiled as standalone units. I added them to header-test-.
      The blacklist was mostly generated by a script, so the reason of the
      breakage should be checked later.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: default avatarJani Nikula <jani.nikula@intel.com>
      Reviewed-by: default avatarJoel Fernandes (Google) <joel@joelfernandes.org>
      43c78d88
    • Masahiro Yamada's avatar
      kbuild: do not create wrappers for header-test-y · c93a0368
      Masahiro Yamada authored
      
      header-test-y does not work with headers in sub-directories.
      
      For example, you may want to write a Makefile, like this:
      
      include/linux/Kbuild:
      
        header-test-y += mtd/nand.h
      
      This entry will create a wrapper include/linux/mtd/nand.hdrtest.c
      with the following content:
      
        #include "mtd/nand.h"
      
      To make this work, we need to add $(srctree)/include/linux to the
      header search path. It would be tedious to add ccflags-y.
      
      Instead, we could change the *.hdrtest.c rule to wrap:
      
        #include "nand.h"
      
      This works for in-tree build since #include "..." searches in the
      relative path from the header with this directive. For O=... build,
      we need to add $(srctree)/include/linux/mtd to the header search path,
      which will be even more tedious.
      
      After all, I thought it would be handier to compile headers directly
      without creating wrappers.
      
      I added a new build rule to compile %.h into %.h.s
      
      The target is %.h.s instead of %.h.o because it is slightly faster.
      Also, as for GCC, an empty assembly is smaller than an empty object.
      
      I wrote the build rule:
      
        $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $<
      
      instead of:
      
        $(CC) $(c_flags) -S -o $@ -x c $<
      
      Both work fine with GCC, but the latter is bad for Clang.
      
      This comes down to the difference in the -Wunused-function policy.
      GCC does not warn about unused 'static inline' functions at all.
      Clang does not warn about the ones in included headers, but does
      about the ones in the source. So, we should handle headers as
      headers, not as source files.
      
      In fact, this has been hidden since commit abb2ea7d ("compiler,
      clang: suppress warning for unused static inline functions"), but we
      should not rely on that.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Tested-by: default avatarJani Nikula <jani.nikula@intel.com>
      c93a0368
  3. Jul 08, 2019
    • Masahiro Yamada's avatar
      kbuild: compile-test exported headers to ensure they are self-contained · d6fc9fcb
      Masahiro Yamada authored
      Multiple people have suggested compile-testing UAPI headers to ensure
      they can be really included from user-space. "make headers_check" is
      obviously not enough to catch bugs, and we often leak unresolved
      references to user-space.
      
      Use the new header-test-y syntax to implement it. Please note exported
      headers are compile-tested with a completely different set of compiler
      flags. The header search path is set to $(objtree)/usr/include since
      exported headers should not include unexported ones.
      
      We use -std=gnu89 for the kernel space since the kernel code highly
      depends on GNU extensions. On the other hand, UAPI headers should be
      written in more standardized C, so they are compiled with -std=c90.
      This will emit errors if C++ style comments, the keyword 'inline', etc.
      are used. Please use C style comments (/* ... */), '__inline__', etc.
      in UAPI headers.
      
      There is additional compiler requirement to enable this test because
      many of UAPI headers include <stdlib.h>, <sys/ioctl.h>, <sys/time.h>,
      etc. directly or indirectly. You cannot use kernel.org pre-built
      toolchains [1] since they lack <stdlib.h>.
      
      I reused CONFIG_CC_CAN_LINK to check the system header availability.
      The intention is slightly different, but a compiler that can link
      userspace programs provide system headers.
      
      For now, a lot of headers need to be excluded because they cannot
      be compiled standalone, but this is a good start point.
      
      [1] https://mirrors.edge.kernel.org/pub/tools/crosstool/index.html
      
      
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      d6fc9fcb
  4. Jul 07, 2019
    • Masahiro Yamada's avatar
      kbuild: add more hints about SUBDIRS replacement · 4e8fc3f5
      Masahiro Yamada authored
      Commit 0126be38 ("kbuild: announce removal of SUBDIRS if used")
      added a hint about the 'SUBDIRS' replacement, but it was not clear
      enough.
      
      Multiple people sent me similar questions, patches. For instance,
      
        https://lkml.org/lkml/2019/1/17/456
      
      
      
      I did not mean to use M= for building a subdirectory in the kernel tree.
      
      From commit 669efc76 ("net: hns3: fix compile error"), people
      already (ab)use M=... to do that because it seems to work to some extent.
      
      Documentation/kbuild/kbuild.txt says M= and KBUILD_EXTMOD are used for
      building external modules.
      
      In fact, Kbuild supports the single target '%/' for this purpose, but
      this may not be noticed much.
      
      Kindly add more hints.
      
      Makefile:213: ================= WARNING ================
      Makefile:214: 'SUBDIRS' will be removed after Linux 5.3
      Makefile:215:
      Makefile:216: If you are building an individual subdirectory
      Makefile:217: in the kernel tree, you can do like this:
      Makefile:218: $ make path/to/dir/you/want/to/build/
      Makefile:219: (Do not forget the trailing slash)
      Makefile:220:
      Makefile:221: If you are building an external module,
      Makefile:222: Please use 'M=' or 'KBUILD_EXTMOD' instead
      Makefile:223: ==========================================
      
      Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      4e8fc3f5
  5. Jul 03, 2019
  6. Jul 01, 2019
  7. Jun 23, 2019
  8. Jun 15, 2019
    • Jani Nikula's avatar
      kbuild: add support for ensuring headers are self-contained · e846f0dc
      Jani Nikula authored
      
      Sometimes it's useful to be able to explicitly ensure certain headers
      remain self-contained, i.e. that they are compilable as standalone
      units, by including and/or forward declaring everything they depend on.
      
      Add special target header-test-y where individual Makefiles can add
      headers to be tested if CONFIG_HEADER_TEST is enabled. This will
      generate a dummy C file per header that gets built as part of extra-y.
      
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e846f0dc
    • Masahiro Yamada's avatar
      kbuild: move hdr-inst shorthand to top Makefile · a5bae54c
      Masahiro Yamada authored
      
      Now that hdr-inst is used only in the top Makefile, move it there
      from scripts/Kbuild.include.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      a5bae54c
    • Masahiro Yamada's avatar
      kbuild: re-implement Makefile.headersinst without recursion · d5470d14
      Masahiro Yamada authored
      
      Since commit fcc8487d ("uapi: export all headers under uapi
      directories"), the headers in uapi directories are all exported by
      default although exceptional cases are still allowed by the syntax
      'no-export-headers'.
      
      The traditional directory descending has been kept (in a somewhat
      hacky way), but it is actually unneeded.
      
      Get rid of it to simplify the code.
      
      Also, handle files one by one instead of the previous per-directory
      processing. This will emit much more log, but I like it.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d5470d14
    • Masahiro Yamada's avatar
      kbuild: add 'headers' target to build up uapi headers in usr/include · 59b2bd05
      Masahiro Yamada authored
      
      In Linux build system, build targets and installation targets are
      separated.
      
      Examples are:
      
       - 'make vmlinux' -> 'make install'
       - 'make modules' -> 'make modules_install'
       - 'make dtbs'    -> 'make dtbs_install'
       - 'make vdso'    -> 'make vdso_install'
      
      The intention is to run the build targets under the normal privilege,
      then the installation targets under the root privilege since we need
      the write permission to the system directories.
      
      We have 'make headers_install' but the corresponding 'make headers'
      stage does not exist. The purpose of headers_install is to provide
      the kernel interface to C library. So, nobody would try to install
      headers to /usr/include directly.
      
      If 'sudo make INSTALL_HDR_PATH=/usr/include headers_install' were run,
      some build artifacts in the kernel tree would be owned by root because
      some of uapi headers are generated by 'uapi-asm-generic', 'archheaders'
      targets.
      
      Anyway, I believe it makes sense to split the header installation into
      two stages.
      
       [1] 'make headers'
          Process headers in uapi directories by scripts/headers_install.sh
          and copy them to usr/include
      
       [2] 'make headers_install'
          Copy '*.h' verbatim from usr/include to $(INSTALL_HDR_PATH)/include
      
      For the backward compatibility, 'headers_install' depends on 'headers'.
      
      Some samples expect uapi headers in usr/include. So, the 'headers'
      target is useful to build up them in the fixed location usr/include
      irrespective of INSTALL_HDR_PATH.
      
      Another benefit is to stop polluting the final destination with the
      time-stamp files '.install' and '.check'. Maybe you can see them in
      your toolchains.
      
      Lastly, my main motivation is to prepare for compile-testing uapi
      headers. To build something, we have to save an object and .*.cmd
      somewhere. The usr/include/ will be the work directory for that.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      59b2bd05
    • Masahiro Yamada's avatar
      kbuild: build all prerequisites of headers_install simultaneously · bdd7714b
      Masahiro Yamada authored
      
      Currently, scripts/unifdef is compiled after scripts_basic,
      uapi-asm-generic, archheaders, and archscripts.
      
      The proper dependency is just scripts_basic. There is no problem
      to compile scripts/unifdef and other headers at the same time.
      
      Split scripts_unifdef out in order to allow more parallel building.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      bdd7714b
    • Masahiro Yamada's avatar
      kbuild: remove build_unifdef target in scripts/Makefile · 2b8481be
      Masahiro Yamada authored
      
      Since commit 2aedcd09 ("kbuild: suppress annoying "... is up to date."
      message"), if_changed and friends nicely suppress "is up to date" messages.
      
      We do not need per-Makefile tricks.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      2b8481be
    • Masahiro Yamada's avatar
      kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples · e949f4c2
      Masahiro Yamada authored
      
      Commit 5318321d ("samples: disable CONFIG_SAMPLES for UML") used
      a big hammer to fix the build errors under the samples/ directory.
      Only some samples actually include uapi headers from usr/include.
      
      Introduce CONFIG_HEADERS_INSTALL since 'depends on HEADERS_INSTALL' is
      clearer than 'depends on !UML'. If this option is enabled, uapi headers
      are installed before starting directory descending.
      
      I added 'depends on HEADERS_INSTALL' to per-sample CONFIG options.
      This allows UML to compile some samples.
      
      $ make ARCH=um allmodconfig samples/
        [ snip ]
        CC [M]  samples/configfs/configfs_sample.o
        CC [M]  samples/kfifo/bytestream-example.o
        CC [M]  samples/kfifo/dma-example.o
        CC [M]  samples/kfifo/inttype-example.o
        CC [M]  samples/kfifo/record-example.o
        CC [M]  samples/kobject/kobject-example.o
        CC [M]  samples/kobject/kset-example.o
        CC [M]  samples/trace_events/trace-events-sample.o
        CC [M]  samples/trace_printk/trace-printk.o
        AR      samples/vfio-mdev/built-in.a
        AR      samples/built-in.a
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e949f4c2
    • Masahiro Yamada's avatar
      kbuild: make gdb_script depend on prepare0 instead of prepare · 7a739ce5
      Masahiro Yamada authored
      
      'gdb_script' needs headers generated by ./Kbuild, which is visited
      by 'prepare0'. None of 'gdb_script' depends on 'prepare'.
      
      Loosen the dependency.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      7a739ce5
    • Masahiro Yamada's avatar
      kbuild: remove stale dependency between Documentation/ and headers_install · 3a51f908
      Masahiro Yamada authored
      
      Commit 8e2faea8 ("Make Documenation depend on headers_install")
      dates back to 2014, which is before Sphinx was introduced for the
      kernel documentation.
      
      Since none of DOC_TARGET requires headers_install, it is strange to
      run it only for the single target "Documentation/".
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      3a51f908
    • Masahiro Yamada's avatar
      kbuild: remove headers_{install,check}_all · f3c8d4c7
      Masahiro Yamada authored
      
      headers_install_all does not make much sense any more because different
      architectures export different set of uapi/linux/ headers. As you see
      in include/uapi/linux/Kbuild, the installation of a.out.h, kvm.h, and
      kvm_para.h is arch-dependent. So, headers_install_all repeats the
      installation/removal of them.
      
      If somebody really thinks it is useful to do headers_install for all
      architectures, it would be possible by small shell-scripting, but
      the top Makefile does not have to provide entry targets just for that
      purpose.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      f3c8d4c7
  9. Jun 09, 2019
  10. Jun 04, 2019
  11. Jun 02, 2019
  12. May 26, 2019
  13. May 19, 2019
  14. May 18, 2019
    • Masahiro Yamada's avatar
      kbuild: check uniqueness of module names · 3a48a919
      Masahiro Yamada authored
      In the recent build test of linux-next, Stephen saw a build error
      caused by a broken .tmp_versions/*.mod file:
      
        https://lkml.org/lkml/2019/5/13/991
      
      
      
      drivers/net/phy/asix.ko and drivers/net/usb/asix.ko have the same
      basename, and there is a race in generating .tmp_versions/asix.mod
      
      Kbuild has not checked this before, and it suddenly shows up with
      obscure error messages when this kind of race occurs.
      
      Non-unique module names cause various sort of problems, but it is
      not trivial to catch them by eyes.
      
      Hence, this script.
      
      It checks not only real modules, but also built-in modules (i.e.
      controlled by tristate CONFIG option, but currently compiled with =y).
      Non-unique names for built-in modules also cause problems because
      /sys/modules/ would fall over.
      
      For the latest kernel, I tested "make allmodconfig all" (or more
      quickly "make allyesconfig modules"), and it detected the following:
      
      warning: same basename if the following are built as modules:
        drivers/regulator/88pm800.ko
        drivers/mfd/88pm800.ko
      warning: same basename if the following are built as modules:
        drivers/gpu/drm/bridge/adv7511/adv7511.ko
        drivers/media/i2c/adv7511.ko
      warning: same basename if the following are built as modules:
        drivers/net/phy/asix.ko
        drivers/net/usb/asix.ko
      warning: same basename if the following are built as modules:
        fs/coda/coda.ko
        drivers/media/platform/coda/coda.ko
      warning: same basename if the following are built as modules:
        drivers/net/phy/realtek.ko
        drivers/net/dsa/realtek.ko
      
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
      3a48a919
    • Masahiro Yamada's avatar
      kbuild: add LICENSES to KBUILD_ALLDIRS · 233c741d
      Masahiro Yamada authored
      
      For *-pkg targets, the LICENSES directory should be included in the
      source tarball.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      233c741d
    • Masahiro Yamada's avatar
      kbuild: terminate Kconfig when $(CC) or $(LD) is missing · 902a6898
      Masahiro Yamada authored
      
      If the compiler specified by $(CC) is not present, the Kconfig stage
      sprinkles 'not found' messages, then succeeds.
      
        $ make CROSS_COMPILE=foo defconfig
        /bin/sh: 1: foogcc: not found
        /bin/sh: 1: foogcc: not found
        *** Default configuration is based on 'x86_64_defconfig'
        ./scripts/gcc-version.sh: 17: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 18: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 19: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 17: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 18: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/gcc-version.sh: 19: ./scripts/gcc-version.sh: foogcc: not found
        ./scripts/clang-version.sh: 11: ./scripts/clang-version.sh: foogcc: not found
        ./scripts/gcc-plugin.sh: 11: ./scripts/gcc-plugin.sh: foogcc: not found
        init/Kconfig:16:warning: 'GCC_VERSION': number is invalid
        #
        # configuration written to .config
        #
      
      Terminate parsing files immediately if $(CC) or $(LD) is not found.
      "make *config" will fail more nicely.
      
        $ make CROSS_COMPILE=foo defconfig
        *** Default configuration is based on 'x86_64_defconfig'
        scripts/Kconfig.include:34: compiler 'foogcc' not found
        make[1]: *** [scripts/kconfig/Makefile;82: defconfig] Error 1
        make: *** [Makefile;557: defconfig] Error 2
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      902a6898
    • Masahiro Yamada's avatar
      kbuild: turn auto.conf.cmd into a mandatory include file · d2f8ae0e
      Masahiro Yamada authored
      syncconfig is responsible for keeping auto.conf up-to-date, so if it
      fails for any reason, the build must be terminated immediately.
      
      However, since commit 9390dff6 ("kbuild: invoke syncconfig if
      include/config/auto.conf.cmd is missing"), Kbuild continues running
      even after syncconfig fails.
      
      You can confirm this by intentionally making syncconfig error out:
      
        diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
        index 08ba146..307b9de 100644
        --- a/scripts/kconfig/confdata.c
        +++ b/scripts/kconfig/confdata.c
        @@ -1023,6 +1023,9 @@ int conf_write_autoconf(int overwrite)
                FILE *out, *tristate, *out_h;
                int i;
      
        +       if (overwrite)
        +               return 1;
        +
                if (!overwrite && is_present(autoconf_name))
                        return 0;
      
      Then, syncconfig fails, but Make would not stop:
      
        $ make -s mrproper allyesconfig defconfig
        $ make
        scripts/kconfig/conf  --syncconfig Kconfig
      
        *** Error during sync of the configuration.
      
        make[2]: *** [scripts/kconfig/Makefile;69: syncconfig] Error 1
        make[1]: *** [Makefile;557: syncconfig] Error 2
        make: *** [include/config/auto.conf.cmd] Deleting file 'include/config/tristate.conf'
        make: Failed to remake makefile 'include/config/auto.conf'.
          SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
          SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
          SYSHDR  arch/x86/include/generated/asm/unistd_64_x32.h
          SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
        [ continue running ... ]
      
      The reason is in the behavior of a pattern rule with multi-targets.
      
        %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
                $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
      
      GNU Make knows this rule is responsible for making all the three files
      simultaneously. As far as examined, auto.conf.cmd is the target in
      question when this rule is invoked. It is probably because auto.conf.cmd
      is included below the inclusion of auto.conf.
      
      The inclusion of auto.conf is mandatory, while that of auto.conf.cmd
      is optional. GNU Make does not care about the failure in the process
      of updating optional include files.
      
      I filed this issue (https://savannah.gnu.org/bugs/?56301
      
      ) in case this
      behavior could be improved somehow in future releases of GNU Make.
      Anyway, it is quite easy to fix our Makefile.
      
      Given that auto.conf is already a mandatory include file, there is no
      reason to stick auto.conf.cmd optional. Make it mandatory as well.
      
      Cc: linux-stable <stable@vger.kernel.org> # 5.0+
      Fixes: 9390dff6 ("kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing")
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d2f8ae0e
    • Masahiro Yamada's avatar
      kbuild: add all Clang-specific flags unconditionally · a1494304
      Masahiro Yamada authored
      
      We do not support old Clang versions. Upgrade your clang version
      if any of these flags is unsupported.
      
      Let's add all flags inside ifdef CONFIG_CC_IS_CLANG unconditionally.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      a1494304
    • Nathan Chancellor's avatar
      7eb8e5f0
    • Masahiro Yamada's avatar
      kbuild: add -Wvla flag unconditionally · 8289f913
      Masahiro Yamada authored
      
      This flag is documented in the GCC 4.6 manual, and recognized by
      Clang as well. Let's rip off the cc-option switch.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      8289f913
    • Masahiro Yamada's avatar
      kbuild: re-enable int-in-bool-context warning · a3bc8864
      Masahiro Yamada authored
      
      This warning was disabled by commit bd664f6b ("disable new
      gcc-7.1.1 warnings for now") just because it was too noisy.
      
      Thanks to Arnd Bergmann, all warnings have been fixed. Now, we are
      ready to re-enable it.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      a3bc8864
  15. May 07, 2019
    • Alexey Gladkov's avatar
      moduleparam: Save information about built-in modules in separate file · 898490c0
      Alexey Gladkov authored
      
      Problem:
      
      When a kernel module is compiled as a separate module, some important
      information about the kernel module is available via .modinfo section of
      the module.  In contrast, when the kernel module is compiled into the
      kernel, that information is not available.
      
      Information about built-in modules is necessary in the following cases:
      
      1. When it is necessary to find out what additional parameters can be
      passed to the kernel at boot time.
      
      2. When you need to know which module names and their aliases are in
      the kernel. This is very useful for creating an initrd image.
      
      Proposal:
      
      The proposed patch does not remove .modinfo section with module
      information from the vmlinux at the build time and saves it into a
      separate file after kernel linking. So, the kernel does not increase in
      size and no additional information remains in it. Information is stored
      in the same format as in the separate modules (null-terminated string
      array). Because the .modinfo section is already exported with a separate
      modules, we are not creating a new API.
      
      It can be easily read in the userspace:
      
      $ tr '\0' '\n' < modules.builtin.modinfo
      ext4.softdep=pre: crc32c
      ext4.license=GPL
      ext4.description=Fourth Extended Filesystem
      ext4.author=Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
      ext4.alias=fs-ext4
      ext4.alias=ext3
      ext4.alias=fs-ext3
      ext4.alias=ext2
      ext4.alias=fs-ext2
      md_mod.alias=block-major-9-*
      md_mod.alias=md
      md_mod.description=MD RAID framework
      md_mod.license=GPL
      md_mod.parmtype=create_on_open:bool
      md_mod.parmtype=start_dirty_degraded:int
      ...
      
      Co-Developed-by: default avatarGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
      Signed-off-by: default avatarGleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
      Signed-off-by: default avatarAlexey Gladkov <gladkov.alexey@gmail.com>
      Acked-by: default avatarJessica Yu <jeyu@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      898490c0
  16. May 06, 2019
  17. May 03, 2019
  18. May 01, 2019
  19. Apr 29, 2019
  20. Apr 24, 2019
    • Kees Cook's avatar
      security: Implement Clang's stack initialization · 709a972e
      Kees Cook authored
      CONFIG_INIT_STACK_ALL turns on stack initialization based on
      -ftrivial-auto-var-init in Clang builds, which has greater coverage
      than CONFIG_GCC_PLUGINS_STRUCTLEAK_BYREF_ALL.
      
      -ftrivial-auto-var-init Clang option provides trivial initializers for
      uninitialized local variables, variable fields and padding.
      
      It has three possible values:
        pattern - uninitialized locals are filled with a fixed pattern
          (mostly 0xAA on 64-bit platforms, see https://reviews.llvm.org/D54604
      
      
          for more details, but 0x000000AA for 32-bit pointers) likely to cause
          crashes when uninitialized value is used;
        zero (it's still debated whether this flag makes it to the official
          Clang release) - uninitialized locals are filled with zeroes;
        uninitialized (default) - uninitialized locals are left intact.
      
      This patch uses only the "pattern" mode when CONFIG_INIT_STACK_ALL is
      enabled.
      
      Developers have the possibility to opt-out of this feature on a
      per-variable basis by using __attribute__((uninitialized)), but such
      use should be well justified in comments.
      
      Co-developed-by: default avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarAlexander Potapenko <glider@google.com>
      Acked-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      709a972e
Loading