1. 11 11月, 2019 4 次提交
  2. 18 10月, 2019 3 次提交
  3. 08 10月, 2019 2 次提交
    • M
      modpost: fix broken sym->namespace for external module builds · 389eb3f5
      Masahiro Yamada 提交于
      Currently, external module builds produce tons of false-positives:
      
        WARNING: module <mod> uses symbol <sym> from namespace <ns>, but does not import it.
      
      Here, the <ns> part shows a random string.
      
      When you build external modules, the symbol info of vmlinux and
      in-kernel modules are read from $(objtree)/Module.symvers, but
      read_dump() is buggy in multiple ways:
      
      [1] When the modpost is run for vmlinux and in-kernel modules,
      sym_extract_namespace() allocates memory for the namespace. On the
      other hand, read_dump() does not, then sym->namespace will point to
      somewhere in the line buffer of get_next_line(). The data in the
      buffer will be replaced soon, and sym->namespace will end up with
      pointing to unrelated data. As a result, check_exports() will show
      random strings in the warning messages.
      
      [2] When there is no namespace, sym_extract_namespace() returns NULL.
      On the other hand, read_dump() sets namespace to an empty string "".
      (but, it will be later replaced with unrelated data due to bug [1].)
      The check_exports() shows a warning unless exp->namespace is NULL,
      so every symbol read from read_dump() emits the warning, which is
      mostly false positive.
      
      To address [1], sym_add_exported() calls strdup() for s->namespace.
      The namespace from sym_extract_namespace() must be freed to avoid
      memory leak.
      
      For [2], I changed the if-conditional in check_exports().
      
      This commit also fixes sym_add_exported() to set s->namespace correctly
      when the symbol is preloaded.
      Reviewed-by: NMatthias Maennich <maennich@google.com>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NJessica Yu <jeyu@kernel.org>
      389eb3f5
    • M
      module: swap the order of symbol.namespace · bf70b050
      Masahiro Yamada 提交于
      Currently, EXPORT_SYMBOL_NS(_GPL) constructs the kernel symbol as
      follows:
      
        __ksymtab_SYMBOL.NAMESPACE
      
      The sym_extract_namespace() in modpost allocates memory for the part
      SYMBOL.NAMESPACE when '.' is contained. One problem is that the pointer
      returned by strdup() is lost because the symbol name will be copied to
      malloc'ed memory by alloc_symbol(). No one will keep track of the
      pointer of strdup'ed memory.
      
      sym->namespace still points to the NAMESPACE part. So, you can free it
      with complicated code like this:
      
         free(sym->namespace - strlen(sym->name) - 1);
      
      It complicates memory free.
      
      To fix it elegantly, I swapped the order of the symbol and the
      namespace as follows:
      
        __ksymtab_NAMESPACE.SYMBOL
      
      then, simplified sym_extract_namespace() so that it allocates memory
      only for the NAMESPACE part.
      
      I prefer this order because it is intuitive and also matches to major
      languages. For example, NAMESPACE::NAME in C++, MODULE.NAME in Python.
      Reviewed-by: NMatthias Maennich <maennich@google.com>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NJessica Yu <jeyu@kernel.org>
      bf70b050
  4. 01 10月, 2019 1 次提交
    • M
      modpost: fix static EXPORT_SYMBOL warnings for UML build · 47346e96
      Masahiro Yamada 提交于
      Johannes Berg reports lots of modpost warnings on ARCH=um builds:
      
      WARNING: "rename" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "lseek" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "ftruncate64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "getuid" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "lseek64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "unlink" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "pwrite64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "close" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "opendir" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "pread64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "syscall" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "readdir" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "readdir64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "futimes" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__lxstat" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "write" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "closedir" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__xstat" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "fsync" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__lxstat64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__fxstat64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "telldir" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "printf" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "readlink" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__sprintf_chk" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "link" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "rmdir" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "fdatasync" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "truncate" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "statfs" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__errno_location" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__xmknod" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "open64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "truncate64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "open" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "read" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "chown" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "chmod" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "utime" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "fchmod" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "seekdir" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "ioctl" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "dup2" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "statfs64" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "utimes" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "mkdir" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "fchown" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__guard" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "symlink" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "access" [vmlinux] is a static EXPORT_SYMBOL
      WARNING: "__stack_smash_handler" [vmlinux] is a static EXPORT_SYMBOL
      
      When you run "make", the modpost is run twice; before linking vmlinux,
      and before building modules. All the warnings above are from the second
      modpost.
      
      The offending symbols are defined not in vmlinux, but in the C library.
      The first modpost is run against the relocatable vmlinux.o, and those
      warnings are nicely suppressed because the SH_UNDEF entries from the
      symbol table clear the ->is_static flag.
      
      The second modpost is run against the executable vmlinux (+ modules),
      where those symbols have been resolved, but the definitions do not
      exist.
      
      This commit fixes it in a straightforward way; suppress the static
      EXPORT_SYMBOL warnings from "vmlinux".
      
      Without this commit, we see valid warnings twice anyway. For example,
      ARCH=arm64 defconfig shows the following warning twice:
      
      WARNING: "HYPERVISOR_platform_op" [vmlinux] is a static EXPORT_SYMBOL_GPL
      
      So, it is reasonable to suppress the second one.
      
      Fixes: 15bfc234 ("modpost: check for static EXPORT_SYMBOL* functions")
      Reported-by: NJohannes Berg <johannes@sipsolutions.net>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: NJohannes Berg <johannes@sipsolutions.net>
      Tested-by: NDenis Efremov <efremov@linux.com>
      47346e96
  5. 14 9月, 2019 2 次提交
  6. 10 9月, 2019 2 次提交
  7. 04 9月, 2019 1 次提交
  8. 14 8月, 2019 1 次提交
    • D
      modpost: check for static EXPORT_SYMBOL* functions · 15bfc234
      Denis Efremov 提交于
      This patch adds a check to warn about static EXPORT_SYMBOL* functions
      during the modpost. In most of the cases, a static symbol marked for
      exporting is an odd combination that should be fixed either by deleting
      the exporting mark or by removing the static attribute and adding the
      appropriate declaration to headers.
      
      This check could help to detect the following problems:
      1. 550113d4 ("i2c: add newly exported functions to the header, too")
      2. 54638c6e ("net: phy: make exported variables non-static")
      3. 98ef2046 ("mm: remove the exporting of totalram_pages")
      4. 73df167c ("s390/zcrypt: remove the exporting of ap_query_configuration")
      5. a57caf8c ("sunrpc/cache: remove the exporting of cache_seq_next")
      6. e4e47306 ("crypto: skcipher - remove the exporting of skcipher_walk_next")
      7. 14b4c48b ("gve: Remove the exporting of gve_probe")
      8. 9b79ee97 ("scsi: libsas: remove the exporting of sas_wait_eh")
      9. ...
      
      The build time impact is very limited and is almost at the unnoticeable
      level (< 1 sec).
      Acked-by: NEmil Velikov <emil.l.velikov@gmail.com>
      Signed-off-by: NDenis Efremov <efremov@linux.com>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      15bfc234
  9. 28 3月, 2019 1 次提交
    • F
      kbuild: modversions: Fix relative CRC byte order interpretation · 54a7151b
      Fredrik Noring 提交于
      Fix commit 56067812 ("kbuild: modversions: add infrastructure for
      emitting relative CRCs") where CRCs are interpreted in host byte order
      rather than proper kernel byte order. The bug is conditional on
      CONFIG_MODULE_REL_CRCS.
      
      For example, when loading a BE module into a BE kernel compiled with a LE
      system, the error "disagrees about version of symbol module_layout" is
      produced. A message such as "Found checksum D7FA6856 vs module 5668FAD7"
      will be given with debug enabled, which indicates an obvious endian
      problem within __kcrctab within the kernel image.
      
      The general solution is to use the macro TO_NATIVE, as is done in
      similar cases throughout modpost.c. With this correction it has been
      verified that a BE kernel compiled with a LE system accepts BE modules.
      
      This change has also been verified with a LE kernel compiled with a LE
      system, in which case TO_NATIVE returns its value unmodified since the
      byte orders match. This is by far the common case.
      
      Fixes: 56067812 ("kbuild: modversions: add infrastructure for emitting relative CRCs")
      Signed-off-by: NFredrik Noring <noring@nocrew.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      54a7151b
  10. 14 3月, 2019 1 次提交
  11. 09 1月, 2019 1 次提交
    • W
      x86, modpost: Replace last remnants of RETPOLINE with CONFIG_RETPOLINE · e4f35891
      WANG Chao 提交于
      Commit
      
        4cd24de3 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
      
      replaced the RETPOLINE define with CONFIG_RETPOLINE checks. Remove the
      remaining pieces.
      
       [ bp: Massage commit message. ]
      
      Fixes: 4cd24de3 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
      Signed-off-by: NWANG Chao <chao.wang@ucloud.cn>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Reviewed-by: NZhenzhong Duan <zhenzhong.duan@oracle.com>
      Reviewed-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Woodhouse <dwmw@amazon.co.uk>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Jessica Yu <jeyu@kernel.org>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
      Cc: Michal Marek <michal.lkml@markovi.net>
      Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tim Chen <tim.c.chen@linux.intel.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: linux-kbuild@vger.kernel.org
      Cc: srinivas.eeda@oracle.com
      Cc: stable <stable@vger.kernel.org>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20181210163725.95977-1-chao.wang@ucloud.cn
      e4f35891
  12. 01 12月, 2018 4 次提交
  13. 21 11月, 2018 2 次提交
  14. 22 8月, 2018 1 次提交
  15. 18 7月, 2018 1 次提交
    • L
      kbuild: Add build salt to the kernel and modules · 9afb719e
      Laura Abbott 提交于
      In Fedora, the debug information is packaged separately (foo-debuginfo) and
      can be installed separately. There's been a long standing issue where only
      one version of a debuginfo info package can be installed at a time. There's
      been an effort for Fedora for parallel debuginfo to rectify this problem.
      
      Part of the requirement to allow parallel debuginfo to work is that build ids
      are unique between builds. The existing upstream rpm implementation ensures
      this by re-calculating the build-id using the version and release as a
      seed. This doesn't work 100% for the kernel because of the vDSO which is
      its own binary and doesn't get updated when embedded.
      
      Fix this by adding some data in an ELF note for both the kernel and modules.
      The data is controlled via a Kconfig option so distributions can set it
      to an appropriate value to ensure uniqueness between builds.
      Suggested-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NLaura Abbott <labbott@redhat.com>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      9afb719e
  16. 17 5月, 2018 5 次提交
  17. 10 3月, 2018 1 次提交
  18. 26 1月, 2018 1 次提交
    • A
      module/retpoline: Warn about missing retpoline in module · caf7501a
      Andi Kleen 提交于
      There's a risk that a kernel which has full retpoline mitigations becomes
      vulnerable when a module gets loaded that hasn't been compiled with the
      right compiler or the right option.
      
      To enable detection of that mismatch at module load time, add a module info
      string "retpoline" at build time when the module was compiled with
      retpoline support. This only covers compiled C source, but assembler source
      or prebuilt object files are not checked.
      
      If a retpoline enabled kernel detects a non retpoline protected module at
      load time, print a warning and report it in the sysfs vulnerability file.
      
      [ tglx: Massaged changelog ]
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: gregkh@linuxfoundation.org
      Cc: torvalds@linux-foundation.org
      Cc: jeyu@kernel.org
      Cc: arjan@linux.intel.com
      Link: https://lkml.kernel.org/r/20180125235028.31211-1-andi@firstfloor.org
      caf7501a
  19. 17 1月, 2018 1 次提交
  20. 13 11月, 2017 1 次提交
    • R
      modpost: detect modules without a MODULE_LICENSE · ba1029c9
      Randy Dunlap 提交于
      Partially revert commit 2fa36568 ("kbuild: soften MODULE_LICENSE
      check") so that modpost detects modules that do not have a
      MODULE_LICENSE.
      
      Sam's commit also changed the fatal error to a warning, which I am
      leaving as is.
      
      This gives advance notice of when a module has no license and will taint
      the kernel if the module is loaded.
      
      This produces the following warnings on x86_64 allmodconfig:
      
          MODPOST 6520 modules
        WARNING: modpost: missing MODULE_LICENSE() in drivers/auxdisplay/img-ascii-lcd.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/gpio/gpio-ath79.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/gpio/gpio-iop.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/iio/accel/kxsd9-i2c.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/iio/adc/qcom-vadc-common.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/media/platform/mtk-vcodec/mtk-vcodec-common.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/media/platform/soc_camera/soc_scale_crop.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/mtd/nand/denali_pci.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/net/phy/cortina.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/pinctrl/pxa/pinctrl-pxa2xx.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/power/reset/zx-reboot.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/rpmsg/qcom_glink_native.o
        WARNING: modpost: missing MODULE_LICENSE() in drivers/staging/comedi/drivers/ni_atmio.o
        WARNING: modpost: missing MODULE_LICENSE() in net/9p/9pnet_xen.o
        WARNING: modpost: missing MODULE_LICENSE() in sound/soc/codecs/snd-soc-pcm512x-spi.o
      Signed-off-by: NRandy Dunlap <rdunlap@infradead.org>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ba1029c9
  21. 07 9月, 2017 1 次提交
  22. 25 7月, 2017 1 次提交
    • W
      modpost: abort if module name is too long · 4fd3e4ef
      Wanlong Gao 提交于
      Module name has a limited length, but currently the build system
      allows the build finishing even if the module name is too long.
      
        CC      /root/kprobe_example/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.mod.o
       /root/kprobe_example/abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.mod.c:9:2:
       warning: initializer-string for array of chars is too long [enabled by default]
        .name = KBUILD_MODNAME,
        ^
      
      but it's merely a warning.
      
      This patch adds the check of the module name length in modpost and stops
      the build properly.
      Signed-off-by: NWanlong Gao <wanlong.gao@gmail.com>
      Signed-off-by: NJessica Yu <jeyu@kernel.org>
      4fd3e4ef
  23. 24 5月, 2017 1 次提交
    • K
      module: Add module name to modinfo · 3e2e857f
      Kees Cook 提交于
      Accessing the mod structure (e.g. for mod->name) prior to having completed
      check_modstruct_version() can result in writing garbage to the error logs
      if the layout of the mod structure loaded from disk doesn't match the
      running kernel's mod structure layout. This kind of mismatch will become
      much more likely if a kernel is built with different randomization seed
      for the struct layout randomization plugin.
      
      Instead, add and use a new modinfo string for logging the module name.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NJessica Yu <jeyu@redhat.com>
      3e2e857f
  24. 02 3月, 2017 1 次提交