Subject: Re: bin/29654 (systrace might corrupt syscall arguments)
To: None <chs@netbsd.org, elad@netbsd.org, netbsd-bugs@netbsd.org,>
From: None <chs@netbsd.org>
List: netbsd-bugs
Date: 12/27/2005 00:32:29
Synopsis: systrace might corrupt syscall arguments

Responsible-Changed-From-To: elad->chs
Responsible-Changed-By: chs@netbsd.org
Responsible-Changed-When: Tue, 27 Dec 2005 00:32:28 +0000
Responsible-Changed-Why:
I fixed it.


State-Changed-From-To: open->closed
State-Changed-By: chs@netbsd.org
State-Changed-When: Tue, 27 Dec 2005 00:32:28 +0000
State-Changed-Why:
the problem is, as the submitter suggested, with the interrupted syscall.
the first connect() queues a message to the systrace daemon,
but when the SIGCHLD is delivered, that syscall returns, leaving
the message still in the queue.  the second connect() constructs a
second message, but does not queue it since STR_PROC_ONQUEUE is still set,
but then waits for a response to the second message anyway. when the
response from the first message comes back, the kernel notices that
the kernel and daemon are out of sync and ignores the response.
the traced process then continues waiting for a response that never comes.

we now prevent the kernel and the daemon from getting out of sync like this
by making the traced process sleep uninterruptibly for the response from
the systrace daemon.