Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Apr 12, 2022
    • Jason A. Donenfeld's avatar
      gcc-plugins: latent_entropy: use /dev/urandom · c40160f2
      Jason A. Donenfeld authored
      While the latent entropy plugin mostly doesn't derive entropy from
      get_random_const() for measuring the call graph, when __latent_entropy is
      applied to a constant, then it's initialized statically to output from
      get_random_const(). In that case, this data is derived from a 64-bit
      seed, which means a buffer of 512 bits doesn't really have that amount
      of compile-time entropy.
      
      This patch fixes that shortcoming by just buffering chunks of
      /dev/urandom output and doling it out as requested.
      
      At the same time, it's important that we don't break the use of
      -frandom-seed, for people who want the runtime benefits of the latent
      entropy plugin, while still having compile-time determinism. In that
      case, we detect whether gcc's set_random_seed() has been called by
      making a call to get_random_seed(noinit=true) in the plugin init
      function, which is called after set_random_seed() is called but before
      anything that calls get_random_seed(noinit=false), and seeing if it's
      zero or not. If it's not zero, we're in deterministic mode, and so we
      just generate numbers with a basic xorshift prng.
      
      Note that we don't detect if -frandom-seed is being used using the
      documented local_tick variable, because it's assigned via:
         local_tick = (unsigned) tv.tv_sec * 1000 + tv.tv_usec / 1000;
      which may well overflow and become -1 on its own, and so isn't
      reliable: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105171
      
      [kees: The 256 byte rnd_buf size was chosen based on average (250),
       median (64), and std deviation (575) bytes of used entropy for a
       defconfig x86_64 build]
      
      Fixes: 38addce8
      
       ("gcc-plugins: Add latent_entropy plugin")
      Cc: stable@vger.kernel.org
      Cc: PaX Team <pageexec@freemail.hu>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20220405222815.21155-1-Jason@zx2c4.com
      c40160f2
  2. Apr 02, 2022
  3. Apr 01, 2022
  4. Mar 30, 2022
    • Masahiro Yamada's avatar
      fixdep: use fflush() and ferror() to ensure successful write to files · 69304379
      Masahiro Yamada authored
      
      Currently, fixdep checks the return value from (v)printf(), but it does
      not ensure the complete write to the .cmd file.
      
      printf() just writes data to the internal buffer, which usually succeeds.
      (Of course, it may fail for another reason, for example when the file
      descriptor is closed, but that is another story.)
      
      When the buffer (4k?) is full, an actual write occurs, and printf() may
      really fail. One of typical cases is "No space left on device" when the
      disk is full.
      
      The data remaining in the buffer will be pushed out to the file when
      the program exits, but we never know if it is successful.
      
      One straight-forward fix would be to add the following code at the end
      of the program.
      
         ret = fflush(stdout);
         if (ret < 0) {
                /* error handling */
         }
      
      However, it is tedious to check the return code in all the call sites
      of printf(), fflush(), fclose(), and whatever can cause actual writes
      to the end device. Doing that lets the program bail out at the first
      failure but is usually not worth the effort.
      
      Instead, let's check the error status from ferror(). This is 'sticky',
      so you need to check it just once. You still need to call fflush().
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarDavid Laight <david.laight@aculab.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      69304379
  5. Mar 28, 2022
  6. Mar 23, 2022
  7. Mar 22, 2022
  8. Mar 21, 2022
    • Kees Cook's avatar
      um: Allow builds with Clang · c7500c1b
      Kees Cook authored
      Add SUBARCH target for Clang+um (which must go last, not alphabetically,
      so the other SUBARCHes are assigned). Remove open-coded "DEFINE"
      macro, instead using linux/kbuild.h's version which was updated to use
      Clang-friendly assembly in commit cf0c3e68 ("kbuild: fix asm-offset
      generation to work with clang"). Redefine "DEFINE_LONGS" in terms of
      "COMMENT" and "DEFINE" so that the intended coment actually has useful
      content. Add a missed "break" to avoid implicit fall-through warnings.
      
      This lets me run KUnit tests with Clang:
      
      $ ./tools/testing/kunit/kunit.py run --make_options LLVM=1
      ...
      
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: David Gow <davidgow@google.com>
      Cc: linux-um@lists.infradead.org
      Cc: linux-kbuild@vger.kernel.org
      Cc: linux-kselftest@vger.kernel.or...
      c7500c1b
  9. Mar 18, 2022
  10. Mar 15, 2022
  11. Mar 13, 2022
  12. Mar 11, 2022
  13. Mar 10, 2022
    • Vasily Gorbik's avatar
      s390/nospec: add an option to use thunk-extern · 1d2ad084
      Vasily Gorbik authored
      
      Currently with -mindirect-branch=thunk and -mfunction-return=thunk compiler
      options expoline thunks are put into individual COMDAT group sections. s390
      is the only architecture which has group sections and it has implications
      for kpatch and objtool tools support.
      
      Using -mindirect-branch=thunk-extern and -mfunction-return=thunk-extern
      is an alternative, which comes with a need to generate all required
      expoline thunks manually. Unfortunately modules area is too far away from
      the kernel image, and expolines from the kernel image cannon be used.
      But since all new distributions (except Debian) build kernels for machine
      generations newer than z10, where "exrl" instruction is available, that
      leaves only 16 expolines thunks possible.
      
      Provide an option to build the kernel with
      -mindirect-branch=thunk-extern and -mfunction-return=thunk-extern for
      z10 or newer. This also requires to postlink expoline thunks into all
      modules explicitly. Currently modules already contain most expolines
      anyhow.
      
      Unfortunately -mindirect-branch=thunk-extern and
      -mfunction-return=thunk-extern options support is broken in gcc <= 11.2.
      Additional compile test is required to verify proper gcc support.
      
      Acked-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      Co-developed-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Signed-off-by: default avatarSumanth Korikkar <sumanthk@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      1d2ad084
  14. Mar 07, 2022
    • Heiko Carstens's avatar
      s390/extable: convert to relative table with data · 3d66718c
      Heiko Carstens authored
      
      Follow arm64, riscv, and x86 and change extable layout to common
      "relative table with data". This allows to get rid of s390 specific
      code in sorttable.c.
      
      The main difference to before is that extable entries do not contain a
      relative function pointer anymore. Instead data and type fields are
      added.
      
      The type field is used to indicate which exception handler needs to be
      called, while the data field is currently unused.
      
      Acked-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      3d66718c
    • Alan Kao's avatar
      nds32: Remove the architecture · aec499c7
      Alan Kao authored
      The nds32 architecture, also known as AndeStar V3, is a custom 32-bit
      RISC target designed by Andes Technologies. Support was added to the
      kernel in 2016 as the replacement RISC-V based V5 processors were
      already announced, and maintained by (current or former) Andes
      employees.
      
      As explained by Alan Kao, new customers are now all using RISC-V,
      and all known nds32 users are already on longterm stable kernels
      provided by Andes, with no development work going into mainline
      support any more.
      
      While the port is still in a reasonably good shape, it only gets
      worse over time without active maintainers, so it seems best
      to remove it before it becomes unusable. As always, if it turns
      out that there are mainline users after all, and they volunteer
      to maintain the port in the future, the removal can be reverted.
      
      Link: https://lore.kernel.org/linux-mm/YhdWNLUhk+x9RAzU@yamatobi.andestech.com/
      Link: https://lore.kernel.org/lkml/20220302065213.82702-1-alankao@andestech.com/
      Link: https://...
      aec499c7
  15. Feb 28, 2022
    • Frank Rowand's avatar
      of: unittest: add program to process EXPECT messages · 8e4296c2
      Frank Rowand authored
      
      If unittest detects a problem it will print a warning or error message
      to the console.  Unittest also triggers warning and error messages from
      other kernel code as a result of intentionally bad unittest data.  This
      has led to confusion as to whether the triggered messages are an
      expected result of a test or whether there is a real problem that is
      independent of unittest.
      
      EXPECT messages were added to unittest to report each triggered message
      that is expected, resulting in verbose console output.
      
      scripts/dtc/of_unittest is a new program that processes the EXPECT
      messages to determine whether the triggered messages occurred and
      also removes the excess verbosity of the EXPECT messages.  More
      information is available from 'scripts/dtc/of_unittest_expect --help'.
      
      Signed-off-by: default avatarFrank Rowand <frank.rowand@sony.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20220201181413.2719955-1-frowand.list@gmail.com
      8e4296c2
  16. Feb 24, 2022
  17. Feb 22, 2022