1. 04 12月, 2018 2 次提交
    • K
      pstore/ram: Report backend assignments with finer granularity · dc80b1ea
      Kees Cook 提交于
      In order to more easily perform automated regression testing, this
      adds pr_debug() calls to report each prz allocation which can then be
      verified against persistent storage. Specifically, seeing the dividing
      line between header, data, any ECC bytes. (And the general assignment
      output is updated to remove the bogus ECC blocksize which isn't actually
      recorded outside the prz instance.)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      dc80b1ea
    • P
      pstore: Avoid duplicate call of persistent_ram_zap() · 7684bd33
      Peng Wang 提交于
      When initialing a prz, if invalid data is found (no PERSISTENT_RAM_SIG),
      the function call path looks like this:
      
      ramoops_init_prz ->
          persistent_ram_new -> persistent_ram_post_init -> persistent_ram_zap
          persistent_ram_zap
      
      As we can see, persistent_ram_zap() is called twice.
      We can avoid this by adding an option to persistent_ram_new(), and
      only call persistent_ram_zap() when it is needed.
      Signed-off-by: NPeng Wang <wangpeng15@xiaomi.com>
      [kees: minor tweak to exit path and commit log]
      Signed-off-by: NKees Cook <keescook@chromium.org>
      7684bd33
  2. 30 11月, 2018 1 次提交
    • K
      pstore/ram: Correctly calculate usable PRZ bytes · 89d328f6
      Kees Cook 提交于
      The actual number of bytes stored in a PRZ is smaller than the
      bytes requested by platform data, since there is a header on each
      PRZ. Additionally, if ECC is enabled, there are trailing bytes used
      as well. Normally this mismatch doesn't matter since PRZs are circular
      buffers and the leading "overflow" bytes are just thrown away. However, in
      the case of a compressed record, this rather badly corrupts the results.
      
      This corruption was visible with "ramoops.mem_size=204800 ramoops.ecc=1".
      Any stored crashes would not be uncompressable (producing a pstorefs
      "dmesg-*.enc.z" file), and triggering errors at boot:
      
        [    2.790759] pstore: crypto_comp_decompress failed, ret = -22!
      
      Backporting this depends on commit 70ad35db ("pstore: Convert console
      write to use ->write_buf")
      Reported-by: NJoel Fernandes <joel@joelfernandes.org>
      Fixes: b0aad7a9 ("pstore: Add compression support to pstore")
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NJoel Fernandes (Google) <joel@joelfernandes.org>
      89d328f6
  3. 22 10月, 2018 2 次提交
  4. 01 10月, 2018 1 次提交
    • K
      pstore/ram: Fix failure-path memory leak in ramoops_init · bac6f6cd
      Kees Cook 提交于
      As reported by nixiaoming, with some minor clarifications:
      
      1) memory leak in ramoops_register_dummy():
         dummy_data = kzalloc(sizeof(*dummy_data), GFP_KERNEL);
         but no kfree() if platform_device_register_data() fails.
      
      2) memory leak in ramoops_init():
         Missing platform_device_unregister(dummy) and kfree(dummy_data)
         if platform_driver_register(&ramoops_driver) fails.
      
      I've clarified the purpose of ramoops_register_dummy(), and added a
      common cleanup routine for all three failure paths to call.
      Reported-by: Nnixiaoming <nixiaoming@huawei.com>
      Cc: stable@vger.kernel.org
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Colin Cross <ccross@android.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Joel Fernandes <joelaf@google.com>
      Cc: Geliang Tang <geliangtang@gmail.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      bac6f6cd
  5. 14 6月, 2018 1 次提交
    • A
      pstore: Remove bogus format string definition · e264abea
      Arnd Bergmann 提交于
      The pstore conversion to timespec64 introduces its own method of passing
      seconds into sscanf() and sprintf() type functions to work around the
      timespec64 definition on 64-bit systems that redefine it to 'timespec'.
      
      That hack is now finally getting removed, but that means we get a (harmless)
      warning once both patches are merged:
      
      fs/pstore/ram.c: In function 'ramoops_read_kmsg_hdr':
      fs/pstore/ram.c:39:29: error: format '%ld' expects argument of type 'long int *', but argument 3 has type 'time64_t *' {aka 'long long int *'} [-Werror=format=]
       #define RAMOOPS_KERNMSG_HDR "===="
                                   ^~~~~~
      fs/pstore/ram.c:167:21: note: in expansion of macro 'RAMOOPS_KERNMSG_HDR'
      
      This removes the pstore specific workaround and uses the same method that
      we have in place for all other functions that print a timespec64.
      
      Related to this, I found that the kasprintf() output contains an incorrect
      nanosecond values for any number starting with zeroes, and I adapt the
      format string accordingly.
      
      Link: https://lkml.org/lkml/2018/5/19/115
      Link: https://lkml.org/lkml/2018/5/16/1080
      Fixes: 0f0d83b99ef7 ("pstore: Convert internal records to timespec64")
      Acked-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      e264abea
  6. 06 6月, 2018 1 次提交
  7. 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
  8. 01 6月, 2017 1 次提交
  9. 20 4月, 2017 1 次提交
    • D
      Annotate hardware config module parameters in fs/pstore/ · b90fe0c4
      David Howells 提交于
      When the kernel is running in secure boot mode, we lock down the kernel to
      prevent userspace from modifying the running kernel image.  Whilst this
      includes prohibiting access to things like /dev/mem, it must also prevent
      access by means of configuring driver modules in such a way as to cause a
      device to access or modify the kernel image.
      
      To this end, annotate module_param* statements that refer to hardware
      configuration and indicate for future reference what type of parameter they
      specify.  The parameter parser in the core sees this information and can
      skip such parameters with an error message if the kernel is locked down.
      The module initialisation then runs as normal, but just sees whatever the
      default values for those parameters is.
      
      Note that we do still need to do the module initialisation because some
      drivers have viable defaults set in case parameters aren't specified and
      some drivers support automatic configuration (e.g. PNP or PCI) in addition
      to manually coded parameters.
      
      This patch annotates drivers in fs/pstore/.
      Suggested-by: NAlan Cox <gnomes@lxorguk.ukuu.org.uk>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NKees Cook <keescook@chromium.org>
      cc: Anton Vorontsov <anton@enomsg.org>
      cc: Colin Cross <ccross@android.com>
      cc: Tony Luck <tony.luck@intel.com>
      b90fe0c4
  10. 08 3月, 2017 5 次提交
  11. 14 2月, 2017 1 次提交
  12. 10 2月, 2017 1 次提交
  13. 16 11月, 2016 7 次提交
  14. 12 11月, 2016 1 次提交
  15. 09 9月, 2016 5 次提交
    • G
      ramoops: move spin_lock_init after kmalloc error checking · f88baf68
      Geliang Tang 提交于
      If cxt->pstore.buf allocated failed, no need to initialize
      cxt->pstore.buf_lock. So this patch moves spin_lock_init() after the
      error checking.
      Signed-off-by: NGeliang Tang <geliangtang@gmail.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      f88baf68
    • M
      pstore/pmsg: drop bounce buffer · 5bf6d1b9
      Mark Salyzyn 提交于
      Removing a bounce buffer copy operation in the pmsg driver path is
      always better. We also gain in overall performance by not requesting
      a vmalloc on every write as this can cause precious RT tasks, such
      as user facing media operation, to stall while memory is being
      reclaimed. Added a write_buf_user to the pstore functions, a backup
      platform write_buf_user that uses the small buffer that is part of
      the instance, and implemented a ramoops write_buf_user that only
      supports PSTORE_TYPE_PMSG.
      Signed-off-by: NMark Salyzyn <salyzyn@android.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      5bf6d1b9
    • N
      pstore/ram: Set pstore flags dynamically · 79d955af
      Namhyung Kim 提交于
      The ramoops can be configured to enable each pstore type by setting
      their size.  In that case, it'd be better not to register disabled types
      in the first place.
      
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Colin Cross <ccross@android.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      79d955af
    • N
      pstore: Split pstore fragile flags · c950fd6f
      Namhyung Kim 提交于
      This patch adds new PSTORE_FLAGS for each pstore type so that they can
      be enabled separately.  This is a preparation for ongoing virtio-pstore
      work to support those types flexibly.
      
      The PSTORE_FLAGS_FRAGILE is changed to PSTORE_FLAGS_DMESG to preserve the
      original behavior.
      
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Colin Cross <ccross@android.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Len Brown <lenb@kernel.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: linux-acpi@vger.kernel.org
      Cc: linux-efi@vger.kernel.org
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      [kees: retained "FRAGILE" for now to make merges easier]
      Signed-off-by: NKees Cook <keescook@chromium.org>
      c950fd6f
    • S
      pstore/ramoops: fixup driver removal · 4407de74
      Sebastian Andrzej Siewior 提交于
      A basic rmmod ramoops segfaults. Let's see why.
      
      Since commit 34f0ec82 ("pstore: Correct the max_dump_cnt clearing of
      ramoops") sets ->max_dump_cnt to zero before looping over ->przs but we
      didn't use it before that either.
      
      And since commit ee1d2674 ("pstore: add pstore unregister") we free
      that memory on rmmod.
      
      But even then, we looped until a NULL pointer or ERR. I don't see where
      it is ensured that the last member is NULL. Let's try this instead:
      simply error recovery and free. Clean up in error case where resources
      were allocated. And then, in the free path, rely on ->max_dump_cnt in
      the free path.
      
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Colin Cross <ccross@android.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Cc: stable@vger.kernel.org # 4.4.x-
      4407de74
  16. 06 8月, 2016 2 次提交
  17. 15 6月, 2016 1 次提交
    • G
      pstore/ram: add Device Tree bindings · 35da6094
      Greg Hackmann 提交于
      ramoops is one of the remaining places where ARM vendors still rely on
      board-specific shims.  Device Tree lets us replace those shims with
      generic code.
      
      These bindings mirror the ramoops module parameters, with two small
      differences:
      
      (1) dump_oops becomes an optional "no-dump-oops" property, since ramoops
          sets dump_oops=1 by default.
      
      (2) mem_type=1 becomes the more self-explanatory "unbuffered" property.
      Signed-off-by: NGreg Hackmann <ghackmann@google.com>
      [fixed platform_get_drvdata() crash, thanks to Brian Norris]
      [switched from u64 to u32 to simplify code, various whitespace fixes]
      [use dev_of_node() to gain code-elimination for CONFIG_OF=n]
      Signed-off-by: NKees Cook <keescook@chromium.org>
      35da6094
  18. 03 6月, 2016 1 次提交
    • G
      pstore: add lzo/lz4 compression support · 8cfc8ddc
      Geliang Tang 提交于
      Like zlib compression in pstore, this patch added lzo and lz4
      compression support so that users can have more options and better
      compression ratio.
      
      The original code treats the compressed data together with the
      uncompressed ECC correction notice by using zlib decompress. The
      ECC correction notice is missing in the decompression process. The
      treatment also makes lzo and lz4 not working. So I treat them
      separately by using pstore_decompress() to treat the compressed
      data, and memcpy() to treat the uncompressed ECC correction notice.
      Signed-off-by: NGeliang Tang <geliangtang@163.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      8cfc8ddc
  19. 11 3月, 2016 1 次提交
  20. 22 10月, 2015 1 次提交
  21. 22 5月, 2015 3 次提交