Merge tag 'trace-v4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Dec 2018 18:35:19 +0000 (10:35 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 6 Dec 2018 18:35:19 +0000 (10:35 -0800)
Pull tracing fix from Steven Rostedt:
 "This is a single commit that fixes a bug in uprobes SDT code due to a
  missing mutex protection"

* tag 'trace-v4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  Uprobes: Fix kernel oops with delayed_uprobe_remove()

1  2 
kernel/events/uprobes.c

diff --combined kernel/events/uprobes.c
index 322e97bbb4370a8ce4da1af39187dbc775fa83d4,98b9312ce6b2933d5baf87c804f811ea2dcf230e..abbd8da9ac21613d6520e1a8533d3fe0b28dccb0
@@@ -572,7 -572,9 +572,9 @@@ static void put_uprobe(struct uprobe *u
                 * gets called, we don't get a chance to remove uprobe from
                 * delayed_uprobe_list from remove_breakpoint(). Do it here.
                 */
+               mutex_lock(&delayed_uprobe_lock);
                delayed_uprobe_remove(uprobe, NULL);
+               mutex_unlock(&delayed_uprobe_lock);
                kfree(uprobe);
        }
  }
@@@ -829,7 -831,7 +831,7 @@@ static int prepare_uprobe(struct uprob
        BUG_ON((uprobe->offset & ~PAGE_MASK) +
                        UPROBE_SWBP_INSN_SIZE > PAGE_SIZE);
  
 -      smp_wmb(); /* pairs with rmb() in find_active_uprobe() */
 +      smp_wmb(); /* pairs with the smp_rmb() in handle_swbp() */
        set_bit(UPROBE_COPY_INSN, &uprobe->flags);
  
   out:
@@@ -2178,18 -2180,10 +2180,18 @@@ static void handle_swbp(struct pt_regs 
         * After we hit the bp, _unregister + _register can install the
         * new and not-yet-analyzed uprobe at the same address, restart.
         */
 -      smp_rmb(); /* pairs with wmb() in install_breakpoint() */
        if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
                goto out;
  
 +      /*
 +       * Pairs with the smp_wmb() in prepare_uprobe().
 +       *
 +       * Guarantees that if we see the UPROBE_COPY_INSN bit set, then
 +       * we must also see the stores to &uprobe->arch performed by the
 +       * prepare_uprobe() call.
 +       */
 +      smp_rmb();
 +
        /* Tracing handlers use ->utask to communicate with fetch methods */
        if (!get_utask())
                goto out;