From owner-svn-src-all@freebsd.org Mon Feb 8 11:55:50 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 361BA9D9EA7; Mon, 8 Feb 2016 11:55:50 +0000 (UTC) (envelope-from koobs.freebsd@gmail.com) Received: from mail-pa0-x231.google.com (mail-pa0-x231.google.com [IPv6:2607:f8b0:400e:c03::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0FF5F1A10; Mon, 8 Feb 2016 11:55:49 +0000 (UTC) (envelope-from koobs.freebsd@gmail.com) Received: by mail-pa0-x231.google.com with SMTP id cy9so72899055pac.0; Mon, 08 Feb 2016 03:55:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:reply-to:subject:references:to:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=F6mzbVYdUiBhZ7HAnr5d9410hP1isqjN1Ir0FELjFSE=; b=T35Xf8Y+6y3GhoDXPDLOfVgy4gq1ekgT/8xSebdxr/ww7dhRU/DAByasZNB5th1tPb vgQ3oKbrdzru3IjgaOz8omJ6GRsgSLSS7yO7YFgM9MJglFrtRpP82VWdqb5ZFS6H0ZlI yO8V9iKd9a2YtaBCuC5BeMiatxCfBt/M8VTxIMXV9sCIN0wg1eizvMalJSkgs/7R+Y2N c2MgMhqF9T/Kn01/OcR2EhtS8HZZ655AbOUb3haOcL5o+lB14+jB+fllXbTU1e9U+AG8 IGzorxROppLxwi+O4q7iCG1iKDCH9varc/EYiZyrP8i+oJxfxw6gtPpvrkZpNTBnStIy 9FwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:reply-to:subject:references:to:from :message-id:date:user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=F6mzbVYdUiBhZ7HAnr5d9410hP1isqjN1Ir0FELjFSE=; b=cMqzPeldzgfqSiiD5Lsv1eUHVMYbWXOhvFeUQ8ehoZyn6FWETCSUiuw557dO00iCqJ cx3fHVL85Cyx0GMJGTujjQqfmr2P6ugE3oXAdRaqsiziDdE9klCC7e8Xk6mQ+JiIfbYH LYvVakrgPqB0Gsqe1sYeJfztzeagnJMdJU5phMul8C57oh4adc+Pb2OUUcSx1V/w49NO 1A9gQFxSms4aZiY5qalGDIdM63zEsnABW+dL/ARcZywgImJSBHaGExOaeqSGl2F1KHaE cOvLn/BMd4Xyjt+bB9FF8ALUZyu/7tuij7v1YjSKF0YnjQOjBBBPx2Sv+E5RjBP8xRFY e31A== X-Gm-Message-State: AG10YOSULvUaYrdWhstKB5nm63tLhTVAyfz7MCtxGzjY+cVJUkgw5GhGj0f5712nT8+tPQ== X-Received: by 10.66.122.8 with SMTP id lo8mr42282489pab.35.1454932549580; Mon, 08 Feb 2016 03:55:49 -0800 (PST) Received: from ?IPv6:2001:44b8:31ae:7b01:ada3:f1e4:c013:2537? (2001-44b8-31ae-7b01-ada3-f1e4-c013-2537.static.ipv6.internode.on.net. [2001:44b8:31ae:7b01:ada3:f1e4:c013:2537]) by smtp.gmail.com with ESMTPSA id x10sm42960410pas.37.2016.02.08.03.55.47 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Feb 2016 03:55:49 -0800 (PST) Sender: Kubilay Kocak Reply-To: koobs@FreeBSD.org Subject: Re: svn commit: r295385 - in head: sys/kern tools/regression/sysvsem References: <201602072212.u17MCdQ6033309@repo.freebsd.org> To: Jilles Tjoelker , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Kubilay Kocak Message-ID: <56B8823F.2090809@FreeBSD.org> Date: Mon, 8 Feb 2016 22:55:43 +1100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Thunderbird/44.0 MIME-Version: 1.0 In-Reply-To: <201602072212.u17MCdQ6033309@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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, 08 Feb 2016 11:55:50 -0000 On 8/02/2016 9:12 AM, Jilles Tjoelker wrote: > Author: jilles > Date: Sun Feb 7 22:12:39 2016 > New Revision: 295385 > URL: https://svnweb.freebsd.org/changeset/base/295385 > > Log: > semget(): Check for [EEXIST] error first. > > Although POSIX literally permits failing with [EINVAL] if IPC_CREAT and > IPC_EXCL were both passed, the semaphore set already exists and has fewer > semaphores than nsems, this does not allow an application to retry safely: > if the [EINVAL] is actually because of the semmsl limit, an infinite loop > would result. > > PR: 206927 > > Modified: > head/sys/kern/sysv_sem.c > head/tools/regression/sysvsem/semtest.c +infinity for bugfix & issue reference & regression test. Thank you Jilles! > Modified: head/sys/kern/sysv_sem.c > ============================================================================== > --- head/sys/kern/sysv_sem.c Sun Feb 7 21:25:08 2016 (r295384) > +++ head/sys/kern/sysv_sem.c Sun Feb 7 22:12:39 2016 (r295385) > @@ -867,6 +867,11 @@ sys_semget(struct thread *td, struct sem > } > if (semid < seminfo.semmni) { > DPRINTF(("found public key\n")); > + if ((semflg & IPC_CREAT) && (semflg & IPC_EXCL)) { > + DPRINTF(("not exclusive\n")); > + error = EEXIST; > + goto done2; > + } > if ((error = ipcperm(td, &sema[semid].u.sem_perm, > semflg & 0700))) { > goto done2; > @@ -876,11 +881,6 @@ sys_semget(struct thread *td, struct sem > error = EINVAL; > goto done2; > } > - if ((semflg & IPC_CREAT) && (semflg & IPC_EXCL)) { > - DPRINTF(("not exclusive\n")); > - error = EEXIST; > - goto done2; > - } > #ifdef MAC > error = mac_sysvsem_check_semget(cred, &sema[semid]); > if (error != 0) > > Modified: head/tools/regression/sysvsem/semtest.c > ============================================================================== > --- head/tools/regression/sysvsem/semtest.c Sun Feb 7 21:25:08 2016 (r295384) > +++ head/tools/regression/sysvsem/semtest.c Sun Feb 7 22:12:39 2016 (r295385) > @@ -152,6 +152,15 @@ main(int argc, char *argv[]) > > print_semid_ds(&s_ds, 0600); > > + errno = 0; > + if (semget(semkey, 1, IPC_CREAT | IPC_EXCL | 0600) != -1 || > + errno != EEXIST) > + err(1, "semget IPC_EXCL 1 did not fail with [EEXIST]"); > + errno = 0; > + if (semget(semkey, 2, IPC_CREAT | IPC_EXCL | 0600) != -1 || > + errno != EEXIST) > + err(1, "semget IPC_EXCL 2 did not fail with [EEXIST]"); > + > for (child_count = 0; child_count < 5; child_count++) { > switch ((child_pid = fork())) { > case -1: