From owner-freebsd-current Tue Dec 24 6:16: 7 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EC68A37B401 for ; Tue, 24 Dec 2002 06:16:05 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C72743EDC for ; Tue, 24 Dec 2002 06:16:05 -0800 (PST) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.6/8.12.6) with ESMTP id gBOEFsIn001413; Tue, 24 Dec 2002 15:16:00 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: "Paul A. Scott" Cc: current@freebsd.org Subject: Re: revoke(2) redux... From: phk@freebsd.org In-Reply-To: Your message of "Tue, 24 Dec 2002 06:09:30 PST." Date: Tue, 24 Dec 2002 15:15:54 +0100 Message-ID: <1412.1040739354@critter.freebsd.dk> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message , "Paul A. Scott" writes: > >-- > >> From: Poul-Henning Kamp >>>void setctty(char *name) { >>> (void) revoke(name); >>> if ((fd = open(name, O_RDWR)) == -1) { >> Isn't there a pretty obvious race between the revoke() and the open() ? >> Wouldn't it in fact make much more sense if revoke(2) was defined as >> int revoke(int fd); /* kick everybody else off */ >> and the code above would look like: >>> if ((fd = open(name, O_RDWR)) == -1) { >>> } >>> (void) revoke(fd); > >But, revoke() invalidates all descriptors for the named path, so any >subsequent operations on the open file descriptor would fail, which defeats >the purpose of open(). I think you missed the fine point in the "kick everybody *else* off" comment. >I think what's needed is some form of serialization >around revoke() and open(). I'm not a master of the init code, but it may be >that the code is inherently non-reentrant, so the original code would then >be okay. There is more code like this in places. The point is you cannot serialize against other processes. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message