From owner-svn-src-all@FreeBSD.ORG Sun May 31 12:54:09 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 25BAF1065679; Sun, 31 May 2009 12:54:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id B73EC8FC08; Sun, 31 May 2009 12:54:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1MAkYB-0001u8-1g; Sun, 31 May 2009 15:54:07 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n4VCs0mg083553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 31 May 2009 15:54:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n4VCs0F8011216; Sun, 31 May 2009 15:54:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n4VCs0Jq011215; Sun, 31 May 2009 15:54:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 31 May 2009 15:54:00 +0300 From: Kostik Belousov To: Jilles Tjoelker Message-ID: <20090531125400.GU1927@deviant.kiev.zoral.com.ua> References: <200905311204.n4VC41GR042549@svn.freebsd.org> <20090531122642.GA18020@stack.nl> <20090531124555.GT1927@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5GtKBH2IVcxTg5OS" Content-Disposition: inline In-Reply-To: <20090531124555.GT1927@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.1 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1MAkYB-0001u8-1g 350072e7ec5269d41efbe5196abfd308 X-Terabit: YES Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Dmitry Chagin Subject: Re: svn commit: r193165 - head/sys/compat/linux X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 May 2009 12:54:09 -0000 --5GtKBH2IVcxTg5OS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 31, 2009 at 03:45:55PM +0300, Kostik Belousov wrote: > On Sun, May 31, 2009 at 02:26:42PM +0200, Jilles Tjoelker wrote: > > On Sun, May 31, 2009 at 12:04:01PM +0000, Dmitry Chagin wrote: > > > Author: dchagin > > > Date: Sun May 31 12:04:01 2009 > > > New Revision: 193165 > > > URL: http://svn.freebsd.org/changeset/base/193165 > >=20 > > > Log: > > > Move new socket flags handling into a separate function as Linux > > > introduced more syscalls which uses these flags. > >=20 > > I think this does not fulfill the purpose of LINUX_SOCK_CLOEXEC exactly: > > if another thread forks and execs at the wrong time, it may inherit the > > socket without the CLOEXEC flag set. > >=20 > > The obvious way to fix this is to implement SOCK_CLOEXEC in the native > > syscalls, in such a way that other threads can never see the new fd > > without the CLOEXEC flag set. > >=20 > > That could be fairly complicated and it is a pretty rare situation, > > however. >=20 > This is well-known issue, that is omnipresent in the linuxolator. > Your analysis is right, but until we implement corresponding > facilities for the native ABI, linuxolator will be in is this state. > Whether we really need to do the work for freebsd binaries is > debatable. >=20 > For the typical case, see linux_common_open().=20 Mostly replying to myself. The fact that your statement about race is right actually points to the deficiency in the implementation of the linux_execve(), as opposed to the bug in the LINUX_SOCK_CLOEXEC handling. Complete execve(2) implementation should do single-threading for the curproc, and singlethreading happens only when all threads except the one doing execve cross the boundary. See call to thread_single in kern_execve. This does not really happen for linux ABI processes, since multithreading is implemented as multiprocessing. When (if) a singlethreading solution will be implemented for linux ABI, exec cannot happen between these two calls, since the thread is still in kernel not on the single-threading boundary. --5GtKBH2IVcxTg5OS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkoifegACgkQC3+MBN1Mb4h9/wCfSQXzhPce7YSbTDsjS3OGstoH HikAniPvTjdVE2WG9MDKvzG5dGf2zYm4 =v8gh -----END PGP SIGNATURE----- --5GtKBH2IVcxTg5OS--