summaryrefslogtreecommitdiffstats
path: root/sys/dev/systrace.c
diff options
context:
space:
mode:
authorprovos <provos@openbsd.org>2002-07-22 04:02:39 +0000
committerprovos <provos@openbsd.org>2002-07-22 04:02:39 +0000
commit00e588e059e159d8dc149863a9f0c3fd48bd6f5e (patch)
tree01d72d6900f7678d6dcd85137d3899b7840fc04f /sys/dev/systrace.c
parentKNF and unbreak PT_GETREGS (diff)
downloadwireguard-openbsd-00e588e059e159d8dc149863a9f0c3fd48bd6f5e.tar.xz
wireguard-openbsd-00e588e059e159d8dc149863a9f0c3fd48bd6f5e.zip
add seqnr to message from kernel, userland needs to quote correct seqnr.
avoids problems where tsleep has been interrupted by a signal.
Diffstat (limited to 'sys/dev/systrace.c')
-rw-r--r--sys/dev/systrace.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/dev/systrace.c b/sys/dev/systrace.c
index 3113e2d07fc..f3b964f0661 100644
--- a/sys/dev/systrace.c
+++ b/sys/dev/systrace.c
@@ -85,6 +85,7 @@ struct str_policy {
#define STR_PROC_WAITANSWER 0x02
#define STR_PROC_SYSCALLRES 0x04
#define STR_PROC_REPORT 0x08 /* Report emulation */
+#define STR_PROC_NEEDSEQNR 0x10 /* Answer must quote seqnr */
struct str_process {
TAILQ_ENTRY(str_process) next;
@@ -101,6 +102,7 @@ struct str_process {
int flags;
short answer;
short error;
+ u_int16_t seqnr; /* expected reply sequence number */
struct str_message msg;
};
@@ -782,6 +784,12 @@ systrace_answer(struct str_process *strp, struct systrace_answer *ans)
goto out;
}
+ /* Check if answer is in sync with us */
+ if (ans->stra_seqnr != strp->seqnr) {
+ error = ESRCH;
+ goto out;
+ }
+
if ((error = systrace_processready(strp)) != 0)
goto out;
@@ -1306,6 +1314,7 @@ systrace_make_msg(struct str_process *strp, int type)
struct proc *p = strp->proc;
int st;
+ msg->msg_seqnr = ++strp->seqnr;
msg->msg_type = type;
msg->msg_pid = strp->pid;
if (strp->policy)