From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1dHD-0001D7-Dc for qemu-devel@nongnu.org; Wed, 06 May 2009 05:18:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1dHB-0001CT-A5 for qemu-devel@nongnu.org; Wed, 06 May 2009 05:18:54 -0400 Received: from [199.232.76.173] (port=52112 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1dHA-0001CD-Ub for qemu-devel@nongnu.org; Wed, 06 May 2009 05:18:53 -0400 Received: from dd21438.kasserver.com ([85.13.141.110]:44297) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M1dHA-0007Nv-ER for qemu-devel@nongnu.org; Wed, 06 May 2009 05:18:52 -0400 Message-ID: <4A0155F6.9000801@opensuse.org> Date: Wed, 06 May 2009 11:18:46 +0200 From: Martin Mohring MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] linux-user: implement pipe2 syscall References: <20090505133048.GA29646@kos.to> <20090505225809.GJ7574@shareable.org> <20090506080023.GA7230@kos.to> In-Reply-To: <20090506080023.GA7230@kos.to> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio Cc: qemu-devel@nongnu.org Riku Voipio wrote: > On Tue, May 05, 2009 at 11:58:09PM +0100, Jamie Lokier wrote: > >> Riku Voipio wrote: >> >>> implement pipe2 syscall. instead of calling pipe2 directly >>> (which was introduced in 2.6.27), emulate the flag functionality >>> with fcntl. >>> > > >> This is wrong with multiple threads if the flag contains FD_CLOEXEC. >> If that situation is possible, please don't do this. >> > > >> The point of pipe2() with FD_CLOEXEC is to be atomic: make sure >> another thread can never see the file descriptor with FD_CLOEXEC not set. >> > > How do we want to handle if "O_CLOEXEC" is not defined on the host OS, because kernel too old (Debian Etch, CentOS 5)? Should it then return ENOSYS? >> If you can't guarantee that, it's better to return ENOSYS as every >> application using pipe2() like this has a fallback to use pipe() and >> FD_CLOEXEC itself, and probably has application logic to protect >> against the race condition. >> > > >> If there's only one thread, or if you can arrange to block any >> concurrent clone/fork/execve calls in other threads (in QEMU) during >> the race window, then it's fine to emulate it with fcntl. >> > > We haven't returned from the pipe2 syscall when setting the flag with fcntl. > Before returning from the syscall, the pipe file descriptors could point > to anything (unitialized memory, zeros, ...) > > > >