1. 21 12月, 2020 5 次提交
    • M
      modpost: turn section mismatches to error from fatal() · c7299d98
      Masahiro Yamada 提交于
      There is code that reports static EXPORT_SYMBOL a few lines below.
      It is not a good idea to bail out here.
      
      I renamed sec_mismatch_fatal to sec_mismatch_warn_only (with logical
      inversion) to match to CONFIG_SECTION_MISMATCH_WARN_ONLY.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      c7299d98
    • M
      modpost: change license incompatibility to error() from fatal() · d6d692fa
      Masahiro Yamada 提交于
      Change fatal() to error() to continue running to report more possible
      issues.
      
      There is no difference in the fact that modpost will fail anyway.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      d6d692fa
    • M
      modpost: turn missing MODULE_LICENSE() into error · 1d6cd392
      Masahiro Yamada 提交于
      Do not create modules with no license tag.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      1d6cd392
    • M
      modpost: refactor error handling and clarify error/fatal difference · 0fd3fbad
      Masahiro Yamada 提交于
      We have 3 log functions. fatal() is special because it lets modpost bail
      out immediately. The difference between warn() and error() is the only
      prefix parts ("WARNING:" vs "ERROR:").
      
      In my understanding, the expected handling of error() is to propagate
      the return code of the function to the exit code of modpost, as
      check_exports() etc. already does. This is a good manner in general
      because we should display as many error messages as possible in a
      single run of modpost.
      
      What is annoying about fatal() is that it kills modpost at the first
      error. People would need to run Kbuild again and again until they fix
      all errors.
      
      But, unfortunately, people tend to do:
      "This case should not be allowed. Let's replace warn() with fatal()."
      
      One of the reasons is probably it is tedious to manually hoist the error
      code to the main() function.
      
      This commit refactors error() so any single call for it automatically
      makes modpost return the error code.
      
      I also added comments in modpost.h for warn(), error(), and fatal().
      
      Please use fatal() only when you have a strong reason to do so.
      For example:
      
        - Memory shortage (i.e. malloc() etc. has failed)
        - The ELF file is broken, and there is no point to continue parsing
        - Something really odd has happened
      
      For general coding errors, please use error().
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: NQuentin Perret <qperret@google.com>
      0fd3fbad
    • M
      modpost: rename merror() to error() · bc72d723
      Masahiro Yamada 提交于
      The log function names, warn(), merror(), fatal() are inconsistent.
      
      Commit 2a116659 ("kbuild: distinguish between errors and warnings
      in modpost") intentionally chose merror() to avoid the conflict with
      the library function error(). See man page of error(3).
      
      But, we are already causing the conflict with warn() because it is also
      a library function. See man page of warn(3). err() would be a problem
      for the same reason.
      
      The common technique to work around name conflicts is to use macros.
      For example:
      
          /* in a header */
          #define error(fmt, ...)  __error(fmt, ##__VA_ARGS__)
          #define warn(fmt, ...)   __warn(fmt, ##__VA_ARGS__)
      
          /* function definition */
          void __error(const char *fmt, ...)
          {
                  <our implementation>
          }
      
          void __warn(const char *fmt, ...)
          {
                  <our implementation>
          }
      
      In this way, we can implement our own warn() and error(), still we can
      include <error.h> and <err.h> with no problem.
      
      And, commit 93c95e52 ("modpost: rework and consolidate logging
      interface") already did that.
      
      Since the log functions are all macros, we can use error() without
      causing "conflicting types" errors.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      bc72d723
  2. 26 10月, 2020 1 次提交
  3. 27 7月, 2020 1 次提交
  4. 07 7月, 2020 1 次提交
  5. 06 6月, 2020 20 次提交
  6. 03 6月, 2020 1 次提交
  7. 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
  8. 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
  9. 19 5月, 2020 1 次提交
  10. 22 4月, 2020 1 次提交
  11. 21 3月, 2020 1 次提交
  12. 19 3月, 2020 1 次提交
  13. 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
  14. 13 3月, 2020 2 次提交
  15. 15 1月, 2020 1 次提交