From mboxrd@z Thu Jan 1 00:00:00 1970 From: NeilBrown Subject: Re: O_CREAT|O_DIRECTORY on nonexisting file with ext4 not posix-compliant Date: Wed, 17 Dec 2014 08:43:05 +1100 Message-ID: <20141217084305.37626f25@notabene.brown> References: <2ECE9D9EEF1F524185270138AE23265947D57FA7@S0MSMAIL112.arc.local> <20141216134926.70253edb@notabene.brown> <2ECE9D9EEF1F524185270138AE23265947D58C1A@S0MSMAIL112.arc.local> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/oih_L6q9C4aVK8m0=Pg_BDE"; protocol="application/pgp-signature" Cc: "linux-fsdevel@vger.kernel.org" , "Michael Kerrisk (man-pages)" To: Fiedler Roman Return-path: Received: from cantor2.suse.de ([195.135.220.15]:35427 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbaLPVnP (ORCPT ); Tue, 16 Dec 2014 16:43:15 -0500 In-Reply-To: <2ECE9D9EEF1F524185270138AE23265947D58C1A@S0MSMAIL112.arc.local> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --Sig_/oih_L6q9C4aVK8m0=Pg_BDE Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 16 Dec 2014 10:42:30 +0000 Fiedler Roman wrote: > > Von: NeilBrown [mailto:neilb@suse.de] > > > > On Mon, 15 Dec 2014 17:39:09 +0000 Fiedler Roman > > > > wrote: > > > > > Hi, > > > > > > It seems that the open syscall is not POSIX-compliant when using both > > > O_CREAT|O_DIRECTORY. This was discussed in [1] with a reference to the > > POSIX > > > documentation. > > > > Given that O_DIRECTORY is not part of POSIX, I don't think that > > POSIX-compliance is an issue here. >=20 > That's strange. Shouldn't [1] be the current 2013 standard with O_DIRECTO= RY=20 > for open on page 1380? If not, all clear. If yes, does Linux adhere to th= e=20 > older version, e.g. 2008 instead? I stand corrected. It is mentioned in POSIX.1-2008. >=20 > > However the implementation does seem to differ from the Linux > > documentation. > > > > I suggest you submit a patch to the manpages project to change > > > > If pathname is not a directory > > > > to > > > > If pathname exists and is not a directory > > > > That should fix the problem. >=20 > When [1] is not the standard to be applied, we are done here. If yes, it = could=20 > be decided if the clarifications from [2] (link included in discussion [3= ]=20 > from previous message) are already relevant. My own perspective is that as O_DIRECTORY was first introduced in Linux, the Linux implementation should be the gold standard. Neither the Linux man page nor the Posix document are explicit about the meaning of "O_DIRECTORY|O_CREAT", and both are explicit about the purpose of O_DIRECTORY being to avoid races and specifically to avoid opening a FIFO or device-special file - a purpose which carries no implications for O_DIRECTORY|O_CREAT in the case where the name doesn't exist. As the documents aren't explicit and the code is, I think the code should w= in. It does seem from your second link that Posix may change to make Linux non-conforming. This seems totally backwards to me. I thought Posix was meant to describe existing practice, not impose upon existing implementatio= ns. So I still think this is a documentation issue. I guess your first statement stands; When [1] is not the standard to be applied, we are done here. My understanding is that Linux follows Posix when it makes sense to do so (which it often does). It isn't clear that it does in this case. NeilBrown P.S. Given that the intended semantics was clearly "Don't open a fifo or special file', it would have been nice of the flag was O_NO_DEV_FIFO... Hindsight gives 20/20 vision? >=20 > > [Snip] >=20 >=20 > [1] http://cfajohnson.com/pdf/Portable_Operating_System_Interface-POSIX.p= df > [2] http://austingroupbugs.net/view.php?id=3D847 > [3] http://www.openwall.com/lists/oss-security/2014/11/26/10 --Sig_/oih_L6q9C4aVK8m0=Pg_BDE Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIVAwUBVJCnaTnsnt1WYoG5AQJ3DQ/+IW8mXelRD3yYW8b3eQXK7pKGhy4YGcs8 nKcIp1GKWQMiZWHN+kgHNadxvq3VnvLE4y/urX1tBuik4TOvpH0UairkaQw5U/Ha Up71LRULMET/pIaDL4B8XdC9pEbWkHi5cy7uhH2mah/YYaUQ5zp8J90V5t7TG8AD xnp0pjlnchrIJbR99ZQB5YBA/wTVXlSw84j0lho/pesU93gIEBX1lfYkugOQSMvc 61/HVKT7lQkYx256e1VhhjB1FMf+JmSoPIXwEHP0uQukp2AlteTDj5s4sRreXWM1 nWahnRWaYwfuCUIvWsveMv8uEny1MCw+/wwRJ0CKmOkBMn+yQXua6iYwDU2EYFSh T/YJ3zfNhGQi0vWWAdXuAZM1hRmeVrlw83veAjXYKbj1YeXuWgQrn5m3E+NQu5rh i13tN2P/pKCmqHu719rBBOe6XdjOV2+vbRsCvFbH0btbviU0ZaHb/SuQKmGjHVDZ qujFkx6Aho1fmTdoVYVbl48VZAvDhfzaXLSamywJ8ZSJCt4PQ9N19U8wGkzqaoEm VAdUFqVZy+3+KwBSNQSobQWurQYNf2EYaQ9iyiVOSjcxNAe64DErU3fDqsJbFxVt j6B/m5Rsw2N0vSZz9OlNIy/yiMmPtiuElgYyuk8VwNAB/6DFiYLwDuhjqg0Z7oNA lgzhJNwdhFQ= =btdg -----END PGP SIGNATURE----- --Sig_/oih_L6q9C4aVK8m0=Pg_BDE--