From owner-freebsd-stable@FreeBSD.ORG Sat Jan 28 10:46:27 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 60D6916A420 for ; Sat, 28 Jan 2006 10:46:27 +0000 (GMT) (envelope-from dwmalone@maths.tcd.ie) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by mx1.FreeBSD.org (Postfix) with SMTP id 8DBFC43D48 for ; Sat, 28 Jan 2006 10:46:26 +0000 (GMT) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie ([134.226.81.10] helo=walton.maths.tcd.ie) by salmon.maths.tcd.ie with SMTP id ; 28 Jan 2006 10:46:25 +0000 (GMT) Date: Sat, 28 Jan 2006 10:46:22 +0000 From: David Malone To: dlm-fb@weaselfish.com Message-ID: <20060128104622.GA44760@walton.maths.tcd.ie> References: <200601272101.k0RL1JB09430@green-dome.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200601272101.k0RL1JB09430@green-dome.village.org> User-Agent: Mutt/1.5.6i Sender: dwmalone@maths.tcd.ie Cc: freebsd-stable@freebsd.org Subject: Re: [5.4] mode bits changed by close(2) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jan 2006 10:46:27 -0000 On Fri, Jan 27, 2006 at 02:01:19PM -0700, dlm-fb@weaselfish.com wrote: > Sticking an fsync() in between the fchmod() and the close() causes the > bits to be cleared as a side-effect of the fsync(). Doing another > fchmod() after the fsync() produces the final expected set{u,g}id > results even after the close. Unfortunately, fsync() is a rather > expensive operation. There is code to clear the suid bits on a file when it is written to, and I guess this is being triggered when the write is flushed rather than when the write call is made. This would explain why flushing before the fsync stops the problem. I've a feeling that it may be difficult to fix this and still have the suid bits cleared if someone writes to a file via mmap, but I'm not completly sure. David.