Skip to content
Snippets Groups Projects
  1. Mar 14, 2019
  2. Mar 13, 2019
    • Mathieu Malaterre's avatar
      blkcg: annotate implicit fall through · f6d85f04
      Mathieu Malaterre authored
      
      There is a plan to build the kernel with -Wimplicit-fallthrough and
      this place in the code produced a warning (W=1).
      
      This commit remove the following warning:
      
        kernel/trace/blktrace.c:725:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
      
      Signed-off-by: default avatarMathieu Malaterre <malat@debian.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      f6d85f04
    • Douglas Anderson's avatar
      tracing: kdb: Fix ftdump to not sleep · 31b265b3
      Douglas Anderson authored
      As reported back in 2016-11 [1], the "ftdump" kdb command triggers a
      BUG for "sleeping function called from invalid context".
      
      kdb's "ftdump" command wants to call ring_buffer_read_prepare() in
      atomic context.  A very simple solution for this is to add allocation
      flags to ring_buffer_read_prepare() so kdb can call it without
      triggering the allocation error.  This patch does that.
      
      Note that in the original email thread about this, it was suggested
      that perhaps the solution for kdb was to either preallocate the buffer
      ahead of time or create our own iterator.  I'm hoping that this
      alternative of adding allocation flags to ring_buffer_read_prepare()
      can be considered since it means I don't need to duplicate more of the
      core trace code into "trace_kdb.c" (for either creating my own
      iterator or re-preparing a ring allocator whose memory was already
      allocated).
      
      NOTE: another option for kdb is to actually figure out how to make it
      reuse the existing ftrace_dump() function and totally eliminate the
      duplication.  This sounds very appealing and actually works (the "sr
      z" command can be seen to properly dump the ftrace buffer).  The
      downside here is that ftrace_dump() fully consumes the trace buffer.
      Unless that is changed I'd rather not use it because it means "ftdump
      | grep xyz" won't be very useful to search the ftrace buffer since it
      will throw away the whole trace on the first grep.  A future patch to
      dump only the last few lines of the buffer will also be hard to
      implement.
      
      [1] https://lkml.kernel.org/r/20161117191605.GA21459@google.com
      
      Link: http://lkml.kernel.org/r/20190308193205.213659-1-dianders@chromium.org
      
      
      
      Reported-by: default avatarBrian Norris <briannorris@chromium.org>
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      31b265b3
  3. Mar 12, 2019
  4. Mar 09, 2019
    • Qian Cai's avatar
      workqueue, lockdep: Fix a memory leak in wq->lock_name · 69a106c0
      Qian Cai authored
      
      The following commit:
      
        669de8bd ("kernel/workqueue: Use dynamic lockdep keys for workqueues")
      
      introduced a memory leak as wq_free_lockdep() calls kfree(wq->lock_name),
      but wq_init_lockdep() does not point wq->lock_name to the newly allocated
      slab object.
      
      This can be reproduced by running LTP fallocate04 followed by oom01 tests:
      
       unreferenced object 0xc0000005876384d8 (size 64):
        comm "fallocate04", pid 26972, jiffies 4297139141 (age 40370.480s)
        hex dump (first 32 bytes):
          28 77 71 5f 63 6f 6d 70 6c 65 74 69 6f 6e 29 65  (wq_completion)e
          78 74 34 2d 72 73 76 2d 63 6f 6e 76 65 72 73 69  xt4-rsv-conversi
        backtrace:
          [<00000000cb452883>] kvasprintf+0x6c/0xe0
          [<000000004654ddac>] kasprintf+0x34/0x60
          [<000000001c68f311>] alloc_workqueue+0x1f8/0x6ac
          [<0000000003c2ad83>] ext4_fill_super+0x23d4/0x3c80 [ext4]
          [<0000000006610538>] mount_bdev+0x25c/0x290
          [<00000000bcf955ec>] ext4_mount+0x28/0x50 [ext4]
          [<0000000016e08fd3>] legacy_get_tree+0x4c/0xb0
          [<0000000042b6a5fc>] vfs_get_tree+0x6c/0x190
          [<00000000268ab022>] do_mount+0xb9c/0x1100
          [<00000000698e6898>] ksys_mount+0x158/0x180
          [<0000000064e391fd>] sys_mount+0x20/0x30
          [<00000000ba378f12>] system_call+0x5c/0x70
      
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: catalin.marinas@arm.com
      Cc: jiangshanlai@gmail.com
      Cc: tj@kernel.org
      Fixes: 669de8bd ("kernel/workqueue: Use dynamic lockdep keys for workqueues")
      Link: https://lkml.kernel.org/r/20190307002731.47371-1-cai@lca.pw
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      69a106c0
    • Bart Van Assche's avatar
      workqueue, lockdep: Fix an alloc_workqueue() error path · 009bb421
      Bart Van Assche authored
      
      This patch fixes a use-after-free and a memory leak in an alloc_workqueue()
      error path.
      
      Repoted by syzkaller and KASAN:
      
        BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:197 [inline]
        BUG: KASAN: use-after-free in lockdep_register_key+0x3b9/0x490 kernel/locking/lockdep.c:1023
        Read of size 8 at addr ffff888090fc2698 by task syz-executor134/7858
      
        CPU: 1 PID: 7858 Comm: syz-executor134 Not tainted 5.0.0-rc8-next-20190301 #1
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        Call Trace:
         __dump_stack lib/dump_stack.c:77 [inline]
         dump_stack+0x172/0x1f0 lib/dump_stack.c:113
         print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
         kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
         __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
         __read_once_size include/linux/compiler.h:197 [inline]
         lockdep_register_key+0x3b9/0x490 kernel/locking/lockdep.c:1023
         wq_init_lockdep kernel/workqueue.c:3444 [inline]
         alloc_workqueue+0x427/0xe70 kernel/workqueue.c:4263
         ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
         misc_open+0x398/0x4c0 drivers/char/misc.c:141
         chrdev_open+0x247/0x6b0 fs/char_dev.c:417
         do_dentry_open+0x488/0x1160 fs/open.c:771
         vfs_open+0xa0/0xd0 fs/open.c:880
         do_last fs/namei.c:3416 [inline]
         path_openat+0x10e9/0x46e0 fs/namei.c:3533
         do_filp_open+0x1a1/0x280 fs/namei.c:3563
         do_sys_open+0x3fe/0x5d0 fs/open.c:1063
         __do_sys_openat fs/open.c:1090 [inline]
         __se_sys_openat fs/open.c:1084 [inline]
         __x64_sys_openat+0x9d/0x100 fs/open.c:1084
         do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
         entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
        Allocated by task 7789:
         save_stack+0x45/0xd0 mm/kasan/common.c:75
         set_track mm/kasan/common.c:87 [inline]
         __kasan_kmalloc mm/kasan/common.c:497 [inline]
         __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:470
         kasan_kmalloc+0x9/0x10 mm/kasan/common.c:511
         __do_kmalloc mm/slab.c:3726 [inline]
         __kmalloc+0x15c/0x740 mm/slab.c:3735
         kmalloc include/linux/slab.h:553 [inline]
         kzalloc include/linux/slab.h:743 [inline]
         alloc_workqueue+0x13c/0xe70 kernel/workqueue.c:4236
         ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
         misc_open+0x398/0x4c0 drivers/char/misc.c:141
         chrdev_open+0x247/0x6b0 fs/char_dev.c:417
         do_dentry_open+0x488/0x1160 fs/open.c:771
         vfs_open+0xa0/0xd0 fs/open.c:880
         do_last fs/namei.c:3416 [inline]
         path_openat+0x10e9/0x46e0 fs/namei.c:3533
         do_filp_open+0x1a1/0x280 fs/namei.c:3563
         do_sys_open+0x3fe/0x5d0 fs/open.c:1063
         __do_sys_openat fs/open.c:1090 [inline]
         __se_sys_openat fs/open.c:1084 [inline]
         __x64_sys_openat+0x9d/0x100 fs/open.c:1084
         do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
         entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
        Freed by task 7789:
         save_stack+0x45/0xd0 mm/kasan/common.c:75
         set_track mm/kasan/common.c:87 [inline]
         __kasan_slab_free+0x102/0x150 mm/kasan/common.c:459
         kasan_slab_free+0xe/0x10 mm/kasan/common.c:467
         __cache_free mm/slab.c:3498 [inline]
         kfree+0xcf/0x230 mm/slab.c:3821
         alloc_workqueue+0xc3e/0xe70 kernel/workqueue.c:4295
         ucma_open+0x76/0x290 drivers/infiniband/core/ucma.c:1732
         misc_open+0x398/0x4c0 drivers/char/misc.c:141
         chrdev_open+0x247/0x6b0 fs/char_dev.c:417
         do_dentry_open+0x488/0x1160 fs/open.c:771
         vfs_open+0xa0/0xd0 fs/open.c:880
         do_last fs/namei.c:3416 [inline]
         path_openat+0x10e9/0x46e0 fs/namei.c:3533
         do_filp_open+0x1a1/0x280 fs/namei.c:3563
         do_sys_open+0x3fe/0x5d0 fs/open.c:1063
         __do_sys_openat fs/open.c:1090 [inline]
         __se_sys_openat fs/open.c:1084 [inline]
         __x64_sys_openat+0x9d/0x100 fs/open.c:1084
         do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
         entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
        The buggy address belongs to the object at ffff888090fc2580
         which belongs to the cache kmalloc-512 of size 512
        The buggy address is located 280 bytes inside of
         512-byte region [ffff888090fc2580, ffff888090fc2780)
      
      Reported-by: default avatar <syzbot+17335689e239ce135d8b@syzkaller.appspotmail.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Fixes: 669de8bd ("kernel/workqueue: Use dynamic lockdep keys for workqueues")
      Link: https://lkml.kernel.org/r/20190303220046.29448-1-bvanassche@acm.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      009bb421
    • Bart Van Assche's avatar
      locking/lockdep: Only call init_rcu_head() after RCU has been initialized · 0126574f
      Bart Van Assche authored
      
      init_data_structures_once() is called for the first time before RCU has
      been initialized. Make sure that init_rcu_head() is called before the
      RCU head is used and after RCU has been initialized.
      
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: longman@redhat.com
      Link: https://lkml.kernel.org/r/c20aa0f0-42ab-a884-d931-7d4ec2bf0cdc@acm.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0126574f
    • Arnd Bergmann's avatar
      locking/lockdep: Avoid a Clang warning · 3fe7522f
      Arnd Bergmann authored
      
      Clang warns about a tentative array definition without a length:
      
        kernel/locking/lockdep.c:845:12: error: tentative array definition assumed to have one element [-Werror]
      
      There is no real reason to do this here, so just set the same length as
      in the real definition later in the same file.  It has to be hidden in
      an #ifdef or annotated __maybe_unused though, to avoid the unused-variable
      warning if CONFIG_PROVE_LOCKING is disabled.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Frederic Weisbecker <frederic@kernel.org>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Link: https://lkml.kernel.org/r/20190307075222.3424524-1-arnd@arndb.de
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3fe7522f
    • Gustavo A. R. Silva's avatar
      perf/core: Mark expected switch fall-through · 43aa378b
      Gustavo A. R. Silva authored
      
      In preparation to enabling -Wimplicit-fallthrough, mark switch cases
      where we are expecting to fall through.
      
      This patch fixes the following warning:
      
        kernel/events/core.c: In function ‘perf_event_parse_addr_filter’:
        kernel/events/core.c:9154:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
            kernel = 1;
            ~~~~~~~^~~
        kernel/events/core.c:9156:3: note: here
           case IF_SRC_FILEADDR:
           ^~~~
      
      Warning level 3 was used: -Wimplicit-fallthrough=3
      
      This patch is part of the ongoing efforts to enable -Wimplicit-fallthrough.
      
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: https://lkml.kernel.org/r/20190212205430.GA8446@embeddedor
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      43aa378b
    • Alexander Shishkin's avatar
      perf/ring_buffer: Use high order allocations for AUX buffers optimistically · 5768402f
      Alexander Shishkin authored
      
      Currently, the AUX buffer allocator will use high-order allocations
      for PMUs that don't support hardware scatter-gather chaining to ensure
      large contiguous blocks of pages, and always use an array of single
      pages otherwise.
      
      There is, however, a tangible performance benefit in using larger chunks
      of contiguous memory even in the latter case, that comes from not having
      to fetch the next page's address at every page boundary. In particular,
      a task running under Intel PT on an Atom CPU shows 1.5%-2% less runtime
      penalty with a single multi-page output region in snapshot mode (no PMI)
      than with multiple single-page output regions, from ~6% down to ~4%. For
      the snapshot mode it does make a difference as it is intended to run over
      long periods of time.
      
      For this reason, change the allocation policy to always optimistically
      start with the highest possible order when allocating pages for the AUX
      buffer, desceding until the allocation succeeds or order zero allocation
      fails.
      
      Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@surriel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: https://lkml.kernel.org/r/20190215114727.62648-2-alexander.shishkin@linux.intel.com
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      5768402f
  5. Mar 08, 2019
  6. Mar 07, 2019
  7. Mar 06, 2019
Loading