From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <335ad4871879ca38a650196a26e6f200@gmx.de> Date: Sat, 1 Aug 2009 15:08:14 -0700 Message-ID: Subject: Re: [9fans] Kernel crash bug From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 348c0c3c-ead5-11e9-9d60-3106f5b1d025 calling vmemchr assumes that the memory isn't being changed by some other proc mapping the same page. if you find the NUL in one pass and then call strcpy or strlen on the pointer later, the other proc might have pulled the NUL in the interim. there is a function in the kernel called validnamedup that both validates a string argument and at the same time makes an in-kernel-memory copy. it's the easiest safe way to handle strings passed to the kernel. namec uses it and luckily almost every string pointer passed to the kernel ends up being interpreted by namec. exec is an exception. when i was working on 9vx, i rewrote exec to remove crashes like this one as well as a handful of other bugs. the code is at http://code.swtch.com/vx32/src/tip/src/9vx/a/sysproc.c#cl-220 and could easily be dropped back into plan 9. russ