void ptrace_notify(int exit_code)
 {
        BUG_ON((exit_code & (0x7f | ~0xffff)) != SIGTRAP);
+       if (unlikely(current->task_works)) {
+               if (test_and_clear_ti_thread_flag(current_thread_info(),
+                                                  TIF_NOTIFY_RESUME)) {
+                       smp_mb__after_clear_bit();
+                       task_work_run();
+               }
+       }
 
        spin_lock_irq(¤t->sighand->siglock);
        ptrace_do_notify(SIGTRAP, exit_code, CLD_TRAPPED);
        struct signal_struct *signal = current->signal;
        int signr;
 
+       if (unlikely(current->task_works)) {
+               if (test_and_clear_ti_thread_flag(current_thread_info(),
+                                                  TIF_NOTIFY_RESUME)) {
+                       smp_mb__after_clear_bit();
+                       task_work_run();
+               }
+       }
+
        if (unlikely(uprobe_deny_signal()))
                return 0;