From owner-freebsd-bugs@FreeBSD.ORG Sat Sep 22 08:50:07 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C444F16A419 for ; Sat, 22 Sep 2007 08:50:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 20A4113C44B for ; Sat, 22 Sep 2007 08:50:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l8M8o6TK082353 for ; Sat, 22 Sep 2007 08:50:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l8M8o6CW082352; Sat, 22 Sep 2007 08:50:06 GMT (envelope-from gnats) Resent-Date: Sat, 22 Sep 2007 08:50:06 GMT Resent-Message-Id: <200709220850.l8M8o6CW082352@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Martin Horcicka Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5FA216A417 for ; Sat, 22 Sep 2007 08:49:59 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id A5F9913C458 for ; Sat, 22 Sep 2007 08:49:59 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l8M8nwZx060140 for ; Sat, 22 Sep 2007 08:49:58 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.1/8.14.1/Submit) id l8M8nwY6060112; Sat, 22 Sep 2007 08:49:58 GMT (envelope-from nobody) Message-Id: <200709220849.l8M8nwY6060112@www.freebsd.org> Date: Sat, 22 Sep 2007 08:49:58 GMT From: Martin Horcicka To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/116543: lockf(1) is broken X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Sep 2007 08:50:07 -0000 >Number: 116543 >Category: bin >Synopsis: lockf(1) is broken >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Sep 22 08:50:06 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Martin Horcicka >Release: 6.2-RELEASE-p6 >Organization: >Environment: Not relevant... >Description: lockf(1) is broken since revision 1.12 of src/usr.bin/lockf/lockf.c. The author of the changes did not realize that the lock file is removed (by default) before being closed by the process that holds it. Consider the following series of events: Process A acquires the lock file Process B tries to acquire it as well but fails and waits Process A removes and closes the lock file Process B wakes up and acquires the lock file which is already removed (!) Process C acquires the lock file because there was no file of that name (!) Now both processes B and C think they hold the lock file (!) >How-To-Repeat: Run this command in two terminals at the same time: lockf lock sh -c 'for n in `jot 10`; do echo mmm; sleep 1; done' One of them will start running and the other will wait. When the first stops running, run it again. Now you can see two processes running at the same time and both thinking they hold the lock file. >Fix: Throw away all changes of src/usr.bin/lockf/lockf.c after revision 1.11. They are wrong. >Release-Note: >Audit-Trail: >Unformatted: