NetBSD Problem Report #42130

From www@NetBSD.org  Sat Sep 26 16:54:34 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 3D3A463B8DF
	for <gnats-bugs@gnats.netbsd.org>; Sat, 26 Sep 2009 16:54:34 +0000 (UTC)
Message-Id: <20090926165434.0BE8463B850@www.NetBSD.org>
Date: Sat, 26 Sep 2009 16:54:34 +0000 (UTC)
From: ef@math.uni-bonn.de
Reply-To: ef@math.uni-bonn.de
To: gnats-bugs@NetBSD.org
Subject: NFS: open(...O_CREAT...) fails, yet file is created
X-Send-Pr-Version: www-1.0

>Number:         42130
>Category:       kern
>Synopsis:       NFS: open(...O_CREAT...) fails, yet file is created
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 26 16:55:00 +0000 2009
>Originator:     Edgar Fuß
>Release:        4.0
>Organization:
Mathematisches Institut der Uni Bonn
>Environment:
NetBSD xxx 4.0_STABLE NetBSD 4.0_STABLE (xxx) #x: xxx amd64
>Description:
There is at least one situation where an open(...O_CREAT...) fails, yet the file in question is created:

1. The file is on NFS
2. flags include O_EXCL
3. mode includes S_ISGID
4. the parent directory belongs to a group the user is not a member of

This happens with both NetBSD and Linux NFS clients (they differ in errno, being EPERM on NetBSD and EIO on Linux).

I suspect this is a consequence of the open(2) being split into multiple NFS RPCs, some of which succeed and some of which fail.

On a local fs, the open() just fails without the file being created.

I'm not sure what POSIX says about this situation; the current behaviour is somewhat surprising to me.
>How-To-Repeat:
On an NFS file system:

mkdir(1) a directory
chown(1) the directory to user:group where user is NOT a member of group
as user, inside the directory, execute an open(2) with flags O_CREAT|O_EXCL and mode S_ISGID   
>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.