1. 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
  2. 05 10月, 2017 1 次提交
    • K
      timer: Remove expires and data arguments from DEFINE_TIMER · 1d27e3e2
      Kees Cook 提交于
      Drop the arguments from the macro and adjust all callers with the
      following script:
      
        perl -pi -e 's/DEFINE_TIMER\((.*), 0, 0\);/DEFINE_TIMER($1);/g;' \
          $(git grep DEFINE_TIMER | cut -d: -f1 | sort -u | grep -v timer.h)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # for m68k parts
      Acked-by: Guenter Roeck <linux@roeck-us.net> # for watchdog parts
      Acked-by: David S. Miller <davem@davemloft.net> # for networking parts
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: Kalle Valo <kvalo@codeaurora.org> # for wireless parts
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Cc: linux-mips@linux-mips.org
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Lai Jiangshan <jiangshanlai@gmail.com>
      Cc: Sebastian Reichel <sre@kernel.org>
      Cc: Kalle Valo <kvalo@qca.qualcomm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: linux1394-devel@lists.sourceforge.net
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: linux-s390@vger.kernel.org
      Cc: linux-wireless@vger.kernel.org
      Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
      Cc: Wim Van Sebroeck <wim@iguana.be>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Ursula Braun <ubraun@linux.vnet.ibm.com>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Harish Patil <harish.patil@cavium.com>
      Cc: Stephen Boyd <sboyd@codeaurora.org>
      Cc: Michael Reed <mdr@sgi.com>
      Cc: Manish Chopra <manish.chopra@cavium.com>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-pm@vger.kernel.org
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Julian Wiedmann <jwi@linux.vnet.ibm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Mark Gross <mark.gross@intel.com>
      Cc: linux-watchdog@vger.kernel.org
      Cc: linux-scsi@vger.kernel.org
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: netdev@vger.kernel.org
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Link: https://lkml.kernel.org/r/1507159627-127660-11-git-send-email-keescook@chromium.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      1d27e3e2
  3. 18 8月, 2017 2 次提交
  4. 06 7月, 2017 1 次提交
    • D
      pstore: Implement show_options · 349d7438
      David Howells 提交于
      Implement the show_options superblock op for pstore as part of a bid to get
      rid of s_options and generic_show_options() to make it easier to implement
      a context-based mount where the mount options can be passed individually
      over a file descriptor.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: Kees Cook <keescook@chromium.org>
      cc: Anton Vorontsov <anton@enomsg.org>
      cc: Colin Cross <ccross@android.com>
      cc: Tony Luck <tony.luck@intel.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      349d7438
  5. 28 6月, 2017 1 次提交
  6. 01 6月, 2017 6 次提交
  7. 28 4月, 2017 2 次提交
    • K
      pstore: Solve lockdep warning by moving inode locks · 3a7d2fd1
      Kees Cook 提交于
      Lockdep complains about a possible deadlock between mount and unlink
      (which is technically impossible), but fixing this improves possible
      future multiple-backend support, and keeps locking in the right order.
      
      The lockdep warning could be triggered by unlinking a file in the
      pstore filesystem:
      
        -> #1 (&sb->s_type->i_mutex_key#14){++++++}:
               lock_acquire+0xc9/0x220
               down_write+0x3f/0x70
               pstore_mkfile+0x1f4/0x460
               pstore_get_records+0x17a/0x320
               pstore_fill_super+0xa4/0xc0
               mount_single+0x89/0xb0
               pstore_mount+0x13/0x20
               mount_fs+0xf/0x90
               vfs_kern_mount+0x66/0x170
               do_mount+0x190/0xd50
               SyS_mount+0x90/0xd0
               entry_SYSCALL_64_fastpath+0x1c/0xb1
      
        -> #0 (&psinfo->read_mutex){+.+.+.}:
               __lock_acquire+0x1ac0/0x1bb0
               lock_acquire+0xc9/0x220
               __mutex_lock+0x6e/0x990
               mutex_lock_nested+0x16/0x20
               pstore_unlink+0x3f/0xa0
               vfs_unlink+0xb5/0x190
               do_unlinkat+0x24c/0x2a0
               SyS_unlinkat+0x16/0x30
               entry_SYSCALL_64_fastpath+0x1c/0xb1
      
        Possible unsafe locking scenario:
      
              CPU0                    CPU1
              ----                    ----
         lock(&sb->s_type->i_mutex_key#14);
                                      lock(&psinfo->read_mutex);
                                      lock(&sb->s_type->i_mutex_key#14);
         lock(&psinfo->read_mutex);
      Reported-by: NMarta Lofstedt <marta.lofstedt@intel.com>
      Reported-by: NChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      3a7d2fd1
    • G
      pstore: Remove unused vmalloc.h in pmsg · 3509d048
      Geliang Tang 提交于
      Since the vmalloc code has been removed from write_pmsg() in the commit
      "5bf6d1b9 pstore/pmsg: drop bounce buffer", remove the unused header
      vmalloc.h.
      Signed-off-by: NGeliang Tang <geliangtang@gmail.com>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      3509d048
  8. 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
  9. 08 3月, 2017 19 次提交
  10. 25 2月, 2017 1 次提交
  11. 14 2月, 2017 2 次提交
    • K
      pstore: Check for prz allocation in walker · 46418413
      Kees Cook 提交于
      Instead of needing additional checks in callers for unallocated przs,
      perform the check in the walker, which gives us a more universal way to
      handle the situation.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      46418413
    • K
      pstore: Correctly initialize spinlock and flags · 76d5692a
      Kees Cook 提交于
      The ram backend wasn't always initializing its spinlock correctly. Since
      it was coming from kzalloc memory, though, it was harmless on
      architectures that initialize unlocked spinlocks to 0 (at least x86 and
      ARM). This also fixes a possibly ignored flag setting too.
      
      When running under CONFIG_DEBUG_SPINLOCK, the following Oops was visible:
      
      [    0.760836] persistent_ram: found existing buffer, size 29988, start 29988
      [    0.765112] persistent_ram: found existing buffer, size 30105, start 30105
      [    0.769435] persistent_ram: found existing buffer, size 118542, start 118542
      [    0.785960] persistent_ram: found existing buffer, size 0, start 0
      [    0.786098] persistent_ram: found existing buffer, size 0, start 0
      [    0.786131] pstore: using zlib compression
      [    0.790716] BUG: spinlock bad magic on CPU#0, swapper/0/1
      [    0.790729]  lock: 0xffffffc0d1ca9bb0, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
      [    0.790742] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.10.0-rc2+ #913
      [    0.790747] Hardware name: Google Kevin (DT)
      [    0.790750] Call trace:
      [    0.790768] [<ffffff900808ae88>] dump_backtrace+0x0/0x2bc
      [    0.790780] [<ffffff900808b164>] show_stack+0x20/0x28
      [    0.790794] [<ffffff9008460ee0>] dump_stack+0xa4/0xcc
      [    0.790809] [<ffffff9008113cfc>] spin_dump+0xe0/0xf0
      [    0.790821] [<ffffff9008113d3c>] spin_bug+0x30/0x3c
      [    0.790834] [<ffffff9008113e28>] do_raw_spin_lock+0x50/0x1b8
      [    0.790846] [<ffffff9008a2d2ec>] _raw_spin_lock_irqsave+0x54/0x6c
      [    0.790862] [<ffffff90083ac3b4>] buffer_size_add+0x48/0xcc
      [    0.790875] [<ffffff90083acb34>] persistent_ram_write+0x60/0x11c
      [    0.790888] [<ffffff90083aab1c>] ramoops_pstore_write_buf+0xd4/0x2a4
      [    0.790900] [<ffffff90083a9d3c>] pstore_console_write+0xf0/0x134
      [    0.790912] [<ffffff900811c304>] console_unlock+0x48c/0x5e8
      [    0.790923] [<ffffff900811da18>] register_console+0x3b0/0x4d4
      [    0.790935] [<ffffff90083aa7d0>] pstore_register+0x1a8/0x234
      [    0.790947] [<ffffff90083ac250>] ramoops_probe+0x6b8/0x7d4
      [    0.790961] [<ffffff90085ca548>] platform_drv_probe+0x7c/0xd0
      [    0.790972] [<ffffff90085c76ac>] driver_probe_device+0x1b4/0x3bc
      [    0.790982] [<ffffff90085c7ac8>] __device_attach_driver+0xc8/0xf4
      [    0.790996] [<ffffff90085c4bfc>] bus_for_each_drv+0xb4/0xe4
      [    0.791006] [<ffffff90085c7414>] __device_attach+0xd0/0x158
      [    0.791016] [<ffffff90085c7b18>] device_initial_probe+0x24/0x30
      [    0.791026] [<ffffff90085c648c>] bus_probe_device+0x50/0xe4
      [    0.791038] [<ffffff90085c35b8>] device_add+0x3a4/0x76c
      [    0.791051] [<ffffff90087d0e84>] of_device_add+0x74/0x84
      [    0.791062] [<ffffff90087d19b8>] of_platform_device_create_pdata+0xc0/0x100
      [    0.791073] [<ffffff90087d1a2c>] of_platform_device_create+0x34/0x40
      [    0.791086] [<ffffff900903c910>] of_platform_default_populate_init+0x58/0x78
      [    0.791097] [<ffffff90080831fc>] do_one_initcall+0x88/0x160
      [    0.791109] [<ffffff90090010ac>] kernel_init_freeable+0x264/0x31c
      [    0.791123] [<ffffff9008a25bd0>] kernel_init+0x18/0x11c
      [    0.791133] [<ffffff9008082ec0>] ret_from_fork+0x10/0x50
      [    0.793717] console [pstore-1] enabled
      [    0.797845] pstore: Registered ramoops as persistent store backend
      [    0.804647] ramoops: attached 0x100000@0xf7edc000, ecc: 0/0
      
      Fixes: 663deb47 ("pstore: Allow prz to control need for locking")
      Fixes: 10970449 ("pstore: Make spinlock per zone instead of global")
      Reported-by: NBrian Norris <briannorris@chromium.org>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      76d5692a
  12. 10 2月, 2017 1 次提交
  13. 16 11月, 2016 2 次提交
    • K
      ramoops: add pdata NULL check to ramoops_probe · fc46d4e4
      Kees Cook 提交于
      This adds a check for a NULL platform data, which should only be possible
      if a driver incorrectly sets up a probe request without also having defined
      the platform_data structure. This is based on a patch from Geliang Tang.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      fc46d4e4
    • N
      pstore: Convert console write to use ->write_buf · 70ad35db
      Namhyung Kim 提交于
      Maybe I'm missing something, but I don't know why it needs to copy the
      input buffer to psinfo->buf and then write.  Instead we can write the
      input buffer directly.  The only implementation that supports console
      message (i.e. ramoops) already does it for ftrace messages.
      
      For the upcoming virtio backend driver, it needs to protect psinfo->buf
      overwritten from console messages.  If it could use ->write_buf method
      instead of ->write, the problem will be solved easily.
      
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      70ad35db