|
@@ -90,12 +90,17 @@
|
|
|
#define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */
|
|
|
#define PT_TRACESYSGOOD 0x00000004
|
|
|
#define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */
|
|
|
-#define PT_TRACE_FORK 0x00000010
|
|
|
-#define PT_TRACE_VFORK 0x00000020
|
|
|
-#define PT_TRACE_CLONE 0x00000040
|
|
|
-#define PT_TRACE_EXEC 0x00000080
|
|
|
-#define PT_TRACE_VFORK_DONE 0x00000100
|
|
|
-#define PT_TRACE_EXIT 0x00000200
|
|
|
+
|
|
|
+/* PT_TRACE_* event enable flags */
|
|
|
+#define PT_EVENT_FLAG_SHIFT 4
|
|
|
+#define PT_EVENT_FLAG(event) (1 << (PT_EVENT_FLAG_SHIFT + (event) - 1))
|
|
|
+
|
|
|
+#define PT_TRACE_FORK PT_EVENT_FLAG(PTRACE_EVENT_FORK)
|
|
|
+#define PT_TRACE_VFORK PT_EVENT_FLAG(PTRACE_EVENT_VFORK)
|
|
|
+#define PT_TRACE_CLONE PT_EVENT_FLAG(PTRACE_EVENT_CLONE)
|
|
|
+#define PT_TRACE_EXEC PT_EVENT_FLAG(PTRACE_EVENT_EXEC)
|
|
|
+#define PT_TRACE_VFORK_DONE PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE)
|
|
|
+#define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT)
|
|
|
|
|
|
#define PT_TRACE_MASK 0x000003f4
|
|
|
|
|
@@ -145,26 +150,39 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
|
|
|
int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
|
|
|
unsigned long data);
|
|
|
|
|
|
+/**
|
|
|
+ * ptrace_event_enabled - test whether a ptrace event is enabled
|
|
|
+ * @task: ptracee of interest
|
|
|
+ * @event: %PTRACE_EVENT_* to test
|
|
|
+ *
|
|
|
+ * Test whether @event is enabled for ptracee @task.
|
|
|
+ *
|
|
|
+ * Returns %true if @event is enabled, %false otherwise.
|
|
|
+ */
|
|
|
+static inline bool ptrace_event_enabled(struct task_struct *task, int event)
|
|
|
+{
|
|
|
+ return task->ptrace & PT_EVENT_FLAG(event);
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* ptrace_event - possibly stop for a ptrace event notification
|
|
|
- * @mask: %PT_* bit to check in @current->ptrace
|
|
|
- * @event: %PTRACE_EVENT_* value to report if @mask is set
|
|
|
+ * @event: %PTRACE_EVENT_* value to report
|
|
|
* @message: value for %PTRACE_GETEVENTMSG to return
|
|
|
*
|
|
|
- * This checks the @mask bit to see if ptrace wants stops for this event.
|
|
|
- * If so we stop, reporting @event and @message to the ptrace parent.
|
|
|
+ * Check whether @event is enabled and, if so, report @event and @message
|
|
|
+ * to the ptrace parent.
|
|
|
*
|
|
|
* Returns nonzero if we did a ptrace notification, zero if not.
|
|
|
*
|
|
|
* Called without locks.
|
|
|
*/
|
|
|
-static inline int ptrace_event(int mask, int event, unsigned long message)
|
|
|
+static inline int ptrace_event(int event, unsigned long message)
|
|
|
{
|
|
|
- if (mask && likely(!(current->ptrace & mask)))
|
|
|
- return 0;
|
|
|
+ if (likely(!ptrace_event_enabled(current, event)))
|
|
|
+ return false;
|
|
|
current->ptrace_message = message;
|
|
|
ptrace_notify((event << 8) | SIGTRAP);
|
|
|
- return 1;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|