Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Mar 1999 10:48:56 -0800 (PST)
From:      lopez@cisco.com
To:        freebsd-gnats-submit@freebsd.org
Subject:   i386/10531: uu_lock stores wrong pid if lock exists and locking process doesn't
Message-ID:  <19990310184856.5D84C152BB@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         10531
>Category:       i386
>Synopsis:       uu_lock stores wrong pid if lock exists and locking process doesn't
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 10 10:50:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Lawrence D. Lopez
>Release:        3.0
>Organization:
cisco systems/network masters/l3ds
>Environment:
FreeBSD nptestbed2.dtdtools.cisco.com 3.0-RELEASE FreeBSD 3.0-RELEASE #78: Wed Mar 10 12:54:22 EST 1999     lawlopez@nptestbed2.dtdtools.cisco.com:/usr/src/sys/compile/NPTESTBED2  i386

>Description:
/usr/src/lib/libutil/uucplock.c 8.1

If a lock file exists and the processes which created
the lock file does not exist then a process using
uu_lock creates a lock file with the process id which
is in the old lock file.  This prevents subsequent
detection of the fact that the program which created the
lock file still has the lock file locked because the
lock file has the processid of the previous creator
of the lock file in it.

>How-To-Repeat:
1)	compile the following program.
2)	run the following program.   Control C it.
3)	run the following program.   Control Z it.
4)	repeat step 3) until you are bored.

All of the processes in step 3) think they have the lock.
/* cc -o uulock uulock.c -lutil */

main()
{
        char c;
        int i = uu_lock("special");
        if (i == 0) {
                printf("we have the lock\n");
                for (;;) sleep(1);
        }

        printf("we do not have the lock\n");
}

>Fix:
In /usr/src/lib/libutil/uuplock.c
static const char sccsid[] = "@(#)uucplock.c    8.1 (Berkeley) 6/6/93";

Change:
73c73
<       pid_t pid;
---
>       pid_t pid, pid_old;
98c98
<                       if ((pid = get_pid (fd, &err)) == -1)
---
>                       if ((pid_old = get_pid (fd, &err)) == -1)
103c103
<                       if (kill(pid, 0) == 0 || errno != ESRCH)
---
>                       if (kill(pid_old, 0) == 0 || errno != ESRCH)



>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990310184856.5D84C152BB>