1. 31 5月, 2020 10 次提交
  2. 13 5月, 2020 4 次提交
  3. 26 2月, 2020 1 次提交
  4. 30 10月, 2019 1 次提交
  5. 05 6月, 2019 1 次提交
  6. 31 5月, 2019 2 次提交
    • K
      pstore/ram: Run without kernel crash dump region · 8880fa32
      Kees Cook 提交于
      The ram pstore backend has always had the crash dumper frontend enabled
      unconditionally. However, it was possible to effectively disable it
      by setting a record_size=0. All the machinery would run (storing dumps
      to the temporary crash buffer), but 0 bytes would ultimately get stored
      due to there being no przs allocated for dumps. Commit 89d328f6
      ("pstore/ram: Correctly calculate usable PRZ bytes"), however, assumed
      that there would always be at least one allocated dprz for calculating
      the size of the temporary crash buffer. This was, of course, not the
      case when record_size=0, and would lead to a NULL deref trying to find
      the dprz buffer size:
      
      BUG: unable to handle kernel NULL pointer dereference at (null)
      ...
      IP: ramoops_probe+0x285/0x37e (fs/pstore/ram.c:808)
      
              cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size;
      
      Instead, we need to only enable the frontends based on the success of the
      prz initialization and only take the needed actions when those zones are
      available. (This also fixes a possible error in detecting if the ftrace
      frontend should be enabled.)
      Reported-and-tested-by: NYaro Slav <yaro330@gmail.com>
      Fixes: 89d328f6 ("pstore/ram: Correctly calculate usable PRZ bytes")
      Cc: stable@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      8880fa32
    • P
      pstore: Set tfm to NULL on free_buf_for_compression · a9fb94a9
      Pi-Hsun Shih 提交于
      Set tfm to NULL on free_buf_for_compression() after crypto_free_comp().
      
      This avoid a use-after-free when allocate_buf_for_compression()
      and free_buf_for_compression() are called twice. Although
      free_buf_for_compression() freed the tfm, allocate_buf_for_compression()
      won't reinitialize the tfm since the tfm pointer is not NULL.
      
      Fixes: 95047b05 ("pstore: Refactor compression initialization")
      Signed-off-by: NPi-Hsun Shih <pihsun@chromium.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      a9fb94a9
  7. 13 2月, 2019 1 次提交
  8. 04 12月, 2018 5 次提交
    • K
      pstore: Convert buf_lock to semaphore · ea84b580
      Kees Cook 提交于
      Instead of running with interrupts disabled, use a semaphore. This should
      make it easier for backends that may need to sleep (e.g. EFI) when
      performing a write:
      
      |BUG: sleeping function called from invalid context at kernel/sched/completion.c:99
      |in_atomic(): 1, irqs_disabled(): 1, pid: 2236, name: sig-xstate-bum
      |Preemption disabled at:
      |[<ffffffff99d60512>] pstore_dump+0x72/0x330
      |CPU: 26 PID: 2236 Comm: sig-xstate-bum Tainted: G      D           4.20.0-rc3 #45
      |Call Trace:
      | dump_stack+0x4f/0x6a
      | ___might_sleep.cold.91+0xd3/0xe4
      | __might_sleep+0x50/0x90
      | wait_for_completion+0x32/0x130
      | virt_efi_query_variable_info+0x14e/0x160
      | efi_query_variable_store+0x51/0x1a0
      | efivar_entry_set_safe+0xa3/0x1b0
      | efi_pstore_write+0x109/0x140
      | pstore_dump+0x11c/0x330
      | kmsg_dump+0xa4/0xd0
      | oops_exit+0x22/0x30
      ...
      Reported-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Fixes: 21b3ddd3 ("efi: Don't use spinlocks for efi vars")
      Signed-off-by: NKees Cook <keescook@chromium.org>
      ea84b580
    • J
      pstore: Map PSTORE_TYPE_* to strings · f0f23e54
      Joel Fernandes (Google) 提交于
      In later patches we will need to map types to names, so create a
      constant table for that which can also be used in different parts of
      old and new code. This saves the type in the PRZ which will be useful
      in later patches.
      
      Instead of having an explicit PSTORE_TYPE_UNKNOWN, just use ..._MAX.
      
      This includes removing the now redundant filename templates which can use
      a single format string. Also, there's no reason to limit the "is it still
      compressed?" test to only PSTORE_TYPE_DMESG when building the pstorefs
      filename. Records are zero-initialized, so a backend would need to have
      explicitly set compressed=1.
      Signed-off-by: NJoel Fernandes (Google) <joel@joelfernandes.org>
      Co-developed-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      f0f23e54
    • K
      pstore: Improve and update some comments and status output · 0eed84ff
      Kees Cook 提交于
      This improves and updates some comments:
       - dump handler comment out of sync from calling convention
       - fix kern-doc typo
      
      and improves status output:
       - reminder that only kernel crash dumps are compressed
       - do not be silent about ECC infrastructure failures
      Signed-off-by: NKees Cook <keescook@chromium.org>
      0eed84ff
    • K
      pstore: Remove needless lock during console writes · b77fa617
      Kees Cook 提交于
      Since the console writer does not use the preallocated crash dump buffer
      any more, there is no reason to perform locking around it.
      
      Fixes: 70ad35db ("pstore: Convert console write to use ->write_buf")
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NJoel Fernandes (Google) <joel@joelfernandes.org>
      b77fa617
    • K
      pstore: Do not use crash buffer for decompression · bdabc8e7
      Kees Cook 提交于
      The pre-allocated compression buffer used for crash dumping was also
      being used for decompression. This isn't technically safe, since it's
      possible the kernel may attempt a crashdump while pstore is populating the
      pstore filesystem (and performing decompression). Instead, just allocate
      a separate buffer for decompression. Correctness is preferred over
      performance here.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      bdabc8e7
  9. 22 10月, 2018 3 次提交
  10. 04 8月, 2018 1 次提交
  11. 06 6月, 2018 1 次提交
  12. 07 4月, 2018 1 次提交
    • T
      pstore: fix crypto dependencies without compression · e698aaf3
      Tobias Regnery 提交于
      Commit 58eb5b67 ("pstore: fix crypto dependencies") fixed up the crypto
      dependencies but missed the case when no compression is selected.
      
      With CONFIG_PSTORE=y, CONFIG_PSTORE_COMPRESS=n  and CONFIG_CRYPTO=m we see
      the following link error:
      
      fs/pstore/platform.o: In function `pstore_register':
      (.text+0x1b1): undefined reference to `crypto_has_alg'
      (.text+0x205): undefined reference to `crypto_alloc_base'
      fs/pstore/platform.o: In function `pstore_unregister':
      (.text+0x3b0): undefined reference to `crypto_destroy_tfm'
      
      Fix this by checking at compile-time if CONFIG_PSTORE_COMPRESS is enabled.
      
      Fixes: 58eb5b67 ("pstore: fix crypto dependencies")
      Signed-off-by: NTobias Regnery <tobias.regnery@gmail.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      e698aaf3
  13. 16 3月, 2018 1 次提交
    • A
      pstore: fix crypto dependencies · 58eb5b67
      Arnd Bergmann 提交于
      The new crypto API use causes some problems with Kconfig dependencies,
      including this link error:
      
      fs/pstore/platform.o: In function `pstore_register':
      platform.c:(.text+0x248): undefined reference to `crypto_has_alg'
      platform.c:(.text+0x2a0): undefined reference to `crypto_alloc_base'
      fs/pstore/platform.o: In function `pstore_unregister':
      platform.c:(.text+0x498): undefined reference to `crypto_destroy_tfm'
      crypto/lz4hc.o: In function `lz4hc_sdecompress':
      lz4hc.c:(.text+0x1a): undefined reference to `LZ4_decompress_safe'
      crypto/lz4hc.o: In function `lz4hc_decompress_crypto':
      lz4hc.c:(.text+0x5a): undefined reference to `LZ4_decompress_safe'
      crypto/lz4hc.o: In function `lz4hc_scompress':
      lz4hc.c:(.text+0xaa): undefined reference to `LZ4_compress_HC'
      crypto/lz4hc.o: In function `lz4hc_mod_init':
      lz4hc.c:(.init.text+0xf): undefined reference to `crypto_register_alg'
      lz4hc.c:(.init.text+0x1f): undefined reference to `crypto_register_scomp'
      lz4hc.c:(.init.text+0x2f): undefined reference to `crypto_unregister_alg'
      
      The problem is that with CONFIG_CRYPTO=m, we must not 'select CRYPTO_LZ4'
      from a bool symbol, or call crypto API functions from a built-in
      module.
      
      This turns the sub-options into 'tristate' ones so the dependencies
      are honored, and makes the pstore itself select the crypto core
      if necessary.
      
      Fixes: cb3bee03 ("pstore: Use crypto compress API")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      58eb5b67
  14. 10 3月, 2018 1 次提交
    • G
      pstore: Use crypto compress API · cb3bee03
      Geliang Tang 提交于
      In the pstore compression part, we use zlib/lzo/lz4/lz4hc/842
      compression algorithm API to implement pstore compression backends. But
      there are many repeat codes in these implementations. This patch uses
      crypto compress API to simplify these codes.
      
      1) rewrite allocate_buf_for_compression, free_buf_for_compression,
      pstore_compress, pstore_decompress functions using crypto compress API.
      2) drop compress, decompress, allocate, free functions in pstore_zbackend,
      and add zbufsize function to get each different compress buffer size.
      3) use late_initcall to call ramoops_init later, to make sure the crypto
      subsystem has already initialized.
      4) use 'unsigned int' type instead of 'size_t' in pstore_compress,
      pstore_decompress functions' length arguments.
      5) rename 'zlib' to 'deflate' to follow the crypto API's name convention.
      Signed-off-by: NGeliang Tang <geliangtang@gmail.com>
      [kees: tweaked error messages on allocation failures and Kconfig help]
      Signed-off-by: NKees Cook <keescook@chromium.org>
      cb3bee03
  15. 08 3月, 2018 1 次提交
    • K
      pstore: Select compression at runtime · fe1d4758
      Kees Cook 提交于
      To allow for easier build test coverage and run-time testing, this allows
      multiple compression algorithms to be built into pstore. Still only one
      is supported to operate at a time (which can be selected at build time
      or at boot time, similar to how LSMs are selected).
      Signed-off-by: NKees Cook <keescook@chromium.org>
      fe1d4758
  16. 07 3月, 2018 2 次提交
  17. 29 11月, 2017 1 次提交
  18. 22 11月, 2017 1 次提交
    • K
      treewide: Switch DEFINE_TIMER callbacks to struct timer_list * · 24ed960a
      Kees Cook 提交于
      This changes all DEFINE_TIMER() callbacks to use a struct timer_list
      pointer instead of unsigned long. Since the data argument has already been
      removed, none of these callbacks are using their argument currently, so
      this renames the argument to "unused".
      
      Done using the following semantic patch:
      
      @match_define_timer@
      declarer name DEFINE_TIMER;
      identifier _timer, _callback;
      @@
      
       DEFINE_TIMER(_timer, _callback);
      
      @change_callback depends on match_define_timer@
      identifier match_define_timer._callback;
      type _origtype;
      identifier _origarg;
      @@
      
       void
      -_callback(_origtype _origarg)
      +_callback(struct timer_list *unused)
       { ... }
      Signed-off-by: NKees Cook <keescook@chromium.org>
      24ed960a
  19. 12 11月, 2017 1 次提交
    • A
      pstore: Use ktime_get_real_fast_ns() instead of __getnstimeofday() · df27067e
      Arnd Bergmann 提交于
      __getnstimeofday() is a rather odd interface, with a number of quirks:
      
      - The caller may come from NMI context, but the implementation is not NMI safe,
        one way to get there from NMI is
      
            NMI handler:
              something bad
                panic()
                  kmsg_dump()
                    pstore_dump()
                       pstore_record_init()
                         __getnstimeofday()
      
      - The calling conventions are different from any other timekeeping functions,
        to deal with returning an error code during suspended timekeeping.
      
      Address the above issues by using a completely different method to get the
      time: ktime_get_real_fast_ns() is NMI safe and has a reasonable behavior
      when timekeeping is suspended: it returns the time at which it got
      suspended. As Thomas Gleixner explained, this is safe, as
      ktime_get_real_fast_ns() does not call into the clocksource driver that
      might be suspended.
      
      The result can easily be transformed into a timespec structure. Since
      ktime_get_real_fast_ns() was not exported to modules, add the export.
      
      The pstore behavior for the suspended case changes slightly, as it now
      stores the timestamp at which timekeeping was suspended instead of storing
      a zero timestamp.
      
      This change is not addressing y2038-safety, that's subject to a more
      complex follow up patch.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NKees Cook <keescook@chromium.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Colin Cross <ccross@android.com>
      Link: https://lkml.kernel.org/r/20171110152530.1926955-1-arnd@arndb.de
      df27067e
  20. 06 11月, 2017 1 次提交