From owner-svn-src-all@FreeBSD.ORG Mon Nov 22 10:29:16 2010 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 933FA106566B; Mon, 22 Nov 2010 10:29:16 +0000 (UTC) (envelope-from netchild@freebsd.org) Received: from mail.ebusiness-leidinger.de (mail.ebusiness-leidinger.de [217.11.53.44]) by mx1.freebsd.org (Postfix) with ESMTP id 2325B8FC19; Mon, 22 Nov 2010 10:29:15 +0000 (UTC) Received: from outgoing.leidinger.net (p5B32EEA9.dip.t-dialin.net [91.50.238.169]) by mail.ebusiness-leidinger.de (Postfix) with ESMTPSA id 2A8C884400E; Mon, 22 Nov 2010 11:13:20 +0100 (CET) Received: from webmail.leidinger.net (unknown [IPv6:fd73:10c7:2053:1::2:102]) by outgoing.leidinger.net (Postfix) with ESMTP id 08D9924C8; Mon, 22 Nov 2010 11:13:16 +0100 (CET) Received: (from www@localhost) by webmail.leidinger.net (8.14.4/8.13.8/Submit) id oAMAD6Nc014376; Mon, 22 Nov 2010 11:13:06 +0100 (CET) (envelope-from netchild@FreeBSD.org) Received: from pslux.ec.europa.eu (pslux.ec.europa.eu [158.169.9.14]) by webmail.leidinger.net (Horde Framework) with HTTP; Mon, 22 Nov 2010 11:13:06 +0100 Message-ID: <20101122111306.16504je0tt7xe5us@webmail.leidinger.net> Date: Mon, 22 Nov 2010 11:13:06 +0100 From: Alexander Leidinger To: Kostik Belousov References: <201011220907.oAM970To084256@svn.freebsd.org> <20101122093134.GU2392@deviant.kiev.zoral.com.ua> In-Reply-To: <20101122093134.GU2392@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit User-Agent: Dynamic Internet Messaging Program (DIMP) H3 (1.1.4) X-EBL-MailScanner-Information: Please contact the ISP for more information X-EBL-MailScanner-ID: 2A8C884400E.AA2CF X-EBL-MailScanner: Found to be clean X-EBL-MailScanner-SpamCheck: not spam, spamhaus-ZEN, SpamAssassin (not cached, score=1.428, required 6, autolearn=disabled, RDNS_NONE 1.27, TW_MG 0.08, TW_SV 0.08) X-EBL-MailScanner-SpamScore: s X-EBL-MailScanner-From: netchild@freebsd.org X-EBL-MailScanner-Watermark: 1291025601.18835@jDT6E52umj2QxWNHluKRHw X-EBL-Spam-Status: No Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r215664 - in head/sys: compat/linux kern 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: Mon, 22 Nov 2010 10:29:16 -0000 Quoting Kostik Belousov (from Mon, 22 Nov 2010 11:31:34 +0200): > On Mon, Nov 22, 2010 at 09:07:00AM +0000, Alexander Leidinger wrote: >> Author: netchild >> Date: Mon Nov 22 09:06:59 2010 >> New Revision: 215664 >> URL: http://svn.freebsd.org/changeset/base/215664 >> >> Log: >> By using the 32-bit Linux version of Sun's Java Development Kit 1.6 >> on FreeBSD (amd64), invocations of "javac" (or "java") eventually >> end with the output of "Killed" and exit code 137. >> @@ -196,6 +198,12 @@ linux_proc_exit(void *arg __unused, stru >> } else >> EMUL_SHARED_WUNLOCK(&emul_shared_lock); >> >> + if ((shared_flags & EMUL_SHARED_HASXSTAT) != 0) { >> + PROC_LOCK(p); >> + p->p_xstat = shared_xstat; >> + PROC_UNLOCK(p); >> + } > Why is process lock taken there ? The assignment to u_short inside the > properly aligned structure is atomic on all supported architectures, and > the thread that should see side-effect of assignment is the same thread > that does assignment. Change below. >> + >> if (child_clear_tid != NULL) { >> struct linux_sys_futex_args cup; >> int null = 0; >> @@ -257,6 +265,9 @@ linux_proc_exec(void *arg __unused, stru >> if (__predict_false(imgp->sysent == &elf_linux_sysvec >> && p->p_sysent != &elf_linux_sysvec)) >> linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0); >> + if (__predict_false(p->p_sysent == &elf_linux_sysvec)) >> + /* Kill threads regardless of imgp->sysent value */ >> + linux_kill_threads(FIRST_THREAD_IN_PROC(p), SIGKILL); > This is better expressed by > if ((p->p_sysent->sv_flags & SV_ABI_MASK) == SV_ABI_LINUX) Is this OK for you? ---snip--- Index: compat/linux/linux_emul.c =================================================================== --- compat/linux/linux_emul.c (Revision 215664) +++ compat/linux/linux_emul.c (Arbeitskopie) @@ -198,11 +198,8 @@ } else EMUL_SHARED_WUNLOCK(&emul_shared_lock); - if ((shared_flags & EMUL_SHARED_HASXSTAT) != 0) { - PROC_LOCK(p); + if ((shared_flags & EMUL_SHARED_HASXSTAT) != 0) p->p_xstat = shared_xstat; - PROC_UNLOCK(p); - } if (child_clear_tid != NULL) { struct linux_sys_futex_args cup; @@ -265,7 +262,8 @@ if (__predict_false(imgp->sysent == &elf_linux_sysvec && p->p_sysent != &elf_linux_sysvec)) linux_proc_init(FIRST_THREAD_IN_PROC(p), p->p_pid, 0); - if (__predict_false(p->p_sysent == &elf_linux_sysvec)) + if (__predict_false((p->p_sysent->sv_flags & SV_ABI_MASK) == + SV_ABI_LINUX)) /* Kill threads regardless of imgp->sysent value */ linux_kill_threads(FIRST_THREAD_IN_PROC(p), SIGKILL); if (__predict_false(imgp->sysent != &elf_linux_sysvec ---snip--- > Regardless of this mostly cosmetic issue, this is racy. Other > linux thread in the same process might do an execve(3). > More, if execve(3) call fails, then you return into the process > that lacks all threads except the one that called execve(3). How critical is this in your opinion (relative to the issue this patch is fixing)? Do you prefer a backout or do you think the probability that the someone wins the race is low enough? Do you see a solution for the race? Bye, Alexander. -- http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137 This generation doesn't have emotional baggage. We have emotional moving vans. -- Bruce Feirstein