1. 06 3月, 2023 1 次提交
    • Y
      LoongArch: Switch to relative exception tables · a2603778
      Youling Tang 提交于
      mainline inclusion
      from mainline-v6.2-rc1
      commit 3d36f429
      category: feature
      bugzilla: https://gitee.com/openeuler/kernel/issues/I6BWFP
      CVE: NA
      
      --------------------------------
      
      Similar to other architectures such as arm64, x86, riscv and so on, use
      offsets relative to the exception table entry values rather than their
      absolute addresses for both the exception location and the fixup.
      
      However, LoongArch label difference because it will actually produce two
      relocations, a pair of R_LARCH_ADD32 and R_LARCH_SUB32. Take simple code
      below for example:
      
      $ cat test_ex_table.S
      .section .text
      1:
              nop
      .section __ex_table,"a"
              .balign 4
              .long (1b - .)
      .previous
      
      $ loongarch64-unknown-linux-gnu-gcc -c test_ex_table.S
      $ loongarch64-unknown-linux-gnu-readelf -Wr test_ex_table.o
      
      Relocation section '.rela__ex_table' at offset 0x100 contains 2 entries:
          Offset            Info             Type         Symbol's Value   Symbol's Name + Addend
      0000000000000000 0000000600000032 R_LARCH_ADD32    0000000000000000  .L1^B1 + 0
      0000000000000000 0000000500000037 R_LARCH_SUB32    0000000000000000  L0^A + 0
      
      The modpost will complain the R_LARCH_SUB32 relocation, so we need to
      patch modpost.c to skip this relocation for .rela__ex_table section.
      Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
      Signed-off-by: NHuacai Chen <chenhuacai@loongson.cn>
      Change-Id: If42e54904f36a0d7cafc40a75fd89b582fbaa09e
      a2603778
  2. 27 10月, 2022 1 次提交
  3. 19 10月, 2022 2 次提交
  4. 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
  5. 26 10月, 2020 1 次提交
  6. 27 7月, 2020 1 次提交
  7. 07 7月, 2020 1 次提交
  8. 06 6月, 2020 20 次提交
  9. 03 6月, 2020 1 次提交
  10. 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
  11. 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
  12. 19 5月, 2020 1 次提交
  13. 22 4月, 2020 1 次提交
  14. 21 3月, 2020 1 次提交
  15. 19 3月, 2020 1 次提交
  16. 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
  17. 13 3月, 2020 2 次提交
  18. 15 1月, 2020 1 次提交