1. 18 10月, 2022 1 次提交
  2. 03 6月, 2021 1 次提交
    • M
      kbuild: generate Module.symvers only when vmlinux exists · d931a580
      Masahiro Yamada 提交于
      stable inclusion
      from stable-5.10.38
      commit d0736af81151cb6213825034da0e09a7e4ad20ea
      bugzilla: 51875
      CVE: NA
      
      --------------------------------
      
      [ Upstream commit 69bc8d38 ]
      
      The external module build shows the following warning if Module.symvers
      is missing in the kernel tree.
      
        WARNING: Symbol version dump "Module.symvers" is missing.
                 Modules may not have dependencies or modversions.
      
      I think this is an important heads-up because the resulting modules may
      not work as expected. This happens when you did not build the entire
      kernel tree, for example, you might have prepared the minimal setups
      for external modules by 'make defconfig && make modules_preapre'.
      
      A problem is that 'make modules' creates Module.symvers even without
      vmlinux. In this case, that warning is suppressed since Module.symvers
      already exists in spite of its incomplete content.
      
      The incomplete (i.e. invalid) Module.symvers should not be created.
      
      This commit changes the second pass of modpost to dump symbols into
      modules-only.symvers. The final Module.symvers is created by
      concatenating vmlinux.symvers and modules-only.symvers if both exist.
      
      Module.symvers is supposed to collect symbols from both vmlinux and
      modules. It might be a bit confusing, and I am not quite sure if it
      is an official interface, but presumably it is difficult to rename it
      because some tools (e.g. kmod) parse it.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NChen Jun <chenjun102@huawei.com>
      Acked-by: NWeilong Chen <chenweilong@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      d931a580
  3. 26 10月, 2020 1 次提交
  4. 27 7月, 2020 1 次提交
  5. 07 7月, 2020 1 次提交
  6. 06 6月, 2020 20 次提交
  7. 03 6月, 2020 1 次提交
  8. 29 5月, 2020 2 次提交
    • M
      modpost: refactor sech_name() · 565587d8
      Masahiro Yamada 提交于
      Use sym_get_data_by_offset() helper to get access to the .shstrtab
      section data. No functional change is intended because
      elf->sechdrs[elf->secindex_strings].sh_addr is 0 for both ET_REL
      and ET_EXEC object types.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      565587d8
    • M
      modpost: fix potential segmentation fault for addend_i386_rel() · d2e4d05c
      Masahiro Yamada 提交于
      This may not be a practical problem, but the second pass of ARCH=i386
      modpost causes segmentation fault if the -s option is not passed.
      
          MODPOST 12 modules
        Segmentation fault (core dumped)
        make[2]: *** [scripts/Makefile.modpost:94: __modpost] Error 139
        make[1]: *** [Makefile:1339: modules] Error 2
        make[1]: *** Waiting for unfinished jobs....
      
      The segmentation fault occurs when section_rel() is called for vmlinux,
      which is untested in regular builds. The cause of the problem is
      reloc_location() returning a wrong pointer for ET_EXEC object type.
      In this case, you need to subtract sechdr->sh_addr, otherwise it would
      get access beyond the mmap'ed memory.
      
      Add sym_get_data_by_offset() helper to avoid code duplication.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      d2e4d05c
  9. 25 5月, 2020 1 次提交
    • G
      modpost,fixdep: Replace zero-length array with flexible-array · 859c8175
      Gustavo A. R. Silva 提交于
      The current codebase makes use of the zero-length array language
      extension to the C90 standard, but the preferred mechanism to declare
      variable-length types such as these ones is a flexible array member[1][2],
      introduced in C99:
      
      struct foo {
              int stuff;
              struct boo array[];
      };
      
      By making use of the mechanism above, we will get a compiler warning
      in case the flexible array does not occur last in the structure, which
      will help us prevent some kind of undefined behavior bugs from being
      inadvertently introduced[3] to the codebase from now on.
      
      Also, notice that, dynamic memory allocations won't be affected by
      this change:
      
      "Flexible array members have incomplete type, and so the sizeof operator
      may not be applied. As a quirk of the original implementation of
      zero-length arrays, sizeof evaluates to zero."[1]
      
      sizeof(flexible-array-member) triggers a warning because flexible array
      members have incomplete type[1]. There are some instances of code in
      which the sizeof operator is being incorrectly/erroneously applied to
      zero-length arrays and the result is zero. Such instances may be hiding
      some bugs. So, this work (flexible-array member conversions) will also
      help to get completely rid of those sorts of issues.
      
      This issue was found with the help of Coccinelle.
      
      [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
      [2] https://github.com/KSPP/linux/issues/21
      [3] commit 76497732 ("cxgb3/l2t: Fix undefined behaviour")
      Signed-off-by: NGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      859c8175
  10. 19 5月, 2020 1 次提交
  11. 22 4月, 2020 1 次提交
  12. 21 3月, 2020 1 次提交
  13. 19 3月, 2020 1 次提交
  14. 17 3月, 2020 1 次提交
    • J
      modpost: move the namespace field in Module.symvers last · 5190044c
      Jessica Yu 提交于
      In order to preserve backwards compatability with kmod tools, we have to
      move the namespace field in Module.symvers last, as the depmod -e -E
      option looks at the first three fields in Module.symvers to check symbol
      versions (and it's expected they stay in the original order of crc,
      symbol, module).
      
      In addition, update an ancient comment above read_dump() in modpost that
      suggested that the export type field in Module.symvers was optional. I
      suspect that there were historical reasons behind that comment that are
      no longer accurate. We have been unconditionally printing the export
      type since 2.6.18 (commit bd5cbced), which is over a decade ago now.
      
      Fix up read_dump() to treat each field as non-optional. I suspect the
      original read_dump() code treated the export field as optional in order
      to support pre <= 2.6.18 Module.symvers (which did not have the export
      type field). Note that although symbol namespaces are optional, the
      field will not be omitted from Module.symvers if a symbol does not have
      a namespace. In this case, the field will simply be empty and the next
      delimiter or end of line will follow.
      
      Cc: stable@vger.kernel.org
      Fixes: cb9b55d2 ("modpost: add support for symbol namespaces")
      Tested-by: NMatthias Maennich <maennich@google.com>
      Reviewed-by: NMatthias Maennich <maennich@google.com>
      Reviewed-by: NLucas De Marchi <lucas.demarchi@intel.com>
      Signed-off-by: NJessica Yu <jeyu@kernel.org>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      5190044c
  15. 13 3月, 2020 2 次提交
  16. 15 1月, 2020 1 次提交
  17. 23 11月, 2019 3 次提交
    • M
      modpost: respect the previous export when 'exported twice' is warned · 7ef9ab3b
      Masahiro Yamada 提交于
      When 'exported twice' is warned, let sym_add_exported() return without
      updating the symbol info. This respects the previous export, which is
      ordered first in modules.order
      
      This simplifies the code too.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      7ef9ab3b
    • M
      modpost: do not set ->preloaded for symbols from Module.symvers · e4b26c9f
      Masahiro Yamada 提交于
      Now that there is no overwrap between symbols from ELF files and
      ones from Module.symvers.
      
      So, the 'exported twice' warning should be reported irrespective
      of where the symbol in question came from.
      
      The exceptional case is external module; in some cases, we build
      an external module to provide a different version/variant of the
      corresponding in-kernel module, overriding the same set of exported
      symbols.
      
      You can see this use-case in upstream; tools/testing/nvdimm/libnvdimm.ko
      replaces drivers/nvdimm/libnvdimm.ko in order to link it against mocked
      version of core kernel symbols.
      
      So, let's relax the 'exported twice' warning when building external
      modules. The multiple export from external modules is warned only
      when the previous one is from vmlinux or itself.
      
      With this refactoring, the ugly preloading goes away.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      e4b26c9f
    • M
      modpost: stop symbol preloading for modversion CRC · 1743694e
      Masahiro Yamada 提交于
      It is complicated to add mocked-up symbols for pre-handling CRC.
      Handle CRC after all the export symbols in the relevant module
      are registered.
      
      Call handle_modversion() after the handle_symbol() iteration.
      
      In some cases, I see atand-alone __crc_* without __ksymtab_*.
      For example, ARCH=arm allyesconfig produces __crc_ccitt_veneer and
      __crc_itu_t_veneer. I guess they come from crc_ccitt, crc_itu_t,
      respectively. Since __*_veneer are auto-generated symbols, just
      ignore them.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      1743694e