From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sun, 13 Feb 2011 22:50:17 -0500 To: 9fans@9fans.net Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] ratrace problem; debuggers welcome Topicbox-Message-UUID: adffc38c-ead6-11e9-9d60-3106f5b1d025 On Sun Feb 13 19:34:25 EST 2011, rminnich@gmail.com wrote: > there's a race in ratrace: programs can escape. The reason is that the > parent forks a child and writes stop to its ctl file. But the child > can run any number of system calls -- even to completion -- before the > parent writes that stop command. I'm seeing this on arm. at least from the source i have, writing to p->hang after the fork isn't going to do anything. p->hang is only consulted in sysexec. i think you need to add the same test in sysfork. i did notice a similar race in ratrace the other week when i was using it to test some ata raw io. it was an easy way to audit a command sequence. it turns out that printing "." instead of the character for non-ascii is unworkable for some things. my quick hack was to change fmtrwdata to look (something) like this. the nil ptr case may still be difficult to parse. static void fmtrwdata(Fmt* f, char* a, int n, char* suffix) { int i, j, hex; if(a == nil){ fmtprint(f, "%#p/%s", (uintptr)0, suffix); return; } validaddr((ulong)a, n, 0); hex = 0; for(i = 0; i < n; i++) if(a[i] < 0x20 || (uchar)a[i] > 0x7f){ hex = 1; break; } if(hex) fmtprint(f, " %#p/.*H%s", a, n, a, suffix); else fmtprint(f, " %#p/\"%.*s\"%s", a, n, a, suffix } - erik