From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael Kerrisk" Subject: Re: [PATCH] utimensat() non-conformances and fixes [v3] Date: Tue, 3 Jun 2008 13:27:42 +0200 Message-ID: References: <482D4665.4050401@gmail.com> <48401E7E.9090304@gmail.com> <20080603112221.GW28946@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Miklos Szeredi" , drepper@redhat.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-man@vger.kernel.org, linux-fsdevel@vger.kernel.org To: "Al Viro" Return-path: Received: from ug-out-1314.google.com ([66.249.92.172]:52717 "EHLO ug-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753192AbYFCL1o (ORCPT ); Tue, 3 Jun 2008 07:27:44 -0400 Received: by ug-out-1314.google.com with SMTP id h2so65324ugf.16 for ; Tue, 03 Jun 2008 04:27:42 -0700 (PDT) In-Reply-To: <20080603112221.GW28946@ZenIV.linux.org.uk> Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, Jun 3, 2008 at 1:22 PM, Al Viro wrote: > On Tue, Jun 03, 2008 at 01:13:00PM +0200, Miklos Szeredi wrote: >> > > I'm not sure of the correct way to get the required nameidata (to do a >> > > vfs_permission() call) from the file descriptor. Can you give me a >> > > tip there? >> > >> > Could you point me at the right way of doing this? >> >> You don't need nameidata for this at all. Just call permission() with >> a NULL nameidata. >> >> Ugly API? Yes, will be cleaned up if we manage to find some common >> ground with the VFS maintainers. > > As soon as I'm done with sysctls... > > FWIW, I very much doubt that you are right wrt required permissions, though. > AFAICS, intent here is "if you can write to file, you can touch the timestamps > anyway" and having descriptor opened for write gives that, current permissions > be damned. The standard is pretty clear on this point: [[ Only a process with the effective user ID equal to the user ID of the file, or with write access to the file, or with appropriate privileges may use futimens( ) or utimensat( ) with a null pointer as the times argument or with both tv_nsec fields set to the special value UTIME_NOW. ]] The crucial words here are "a process ... with write access to the file" -- in other words, the permissions are determined by the process's credentials, not by the access mode of the file descriptor. I was not 100% sure on that to start with, so I did check it out with one of the folk at The Open Group, to make sure of my understanding. -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html