Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 26 Nov 2014 13:45:42 +0000
From: Fiedler Roman <>
To: "" <>
Subject: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour?


While trying to write a small python helper library for secure opening of
files, I found behaviour of following call unexpected because it created a
file instead of creating/failing in opening a directory:

open("xxx", O_RDONLY|O_CREAT|O_DIRECTORY, 0600) = 3

I call it unexpected, because man-page mentioned:

              If pathname is not a directory, cause the open  to  fail.
              flag is Linux-specific, and was added in kernel version
              to avoid denial-of-service problems if opendir(3) is called on
              FIFO or tape device.

The only topic I found dealing with such issue was [1].

Is the man page just wrong or what would be the correct behaviour of that
call? Is it likely, that some other tool could also end up with that,
illogic combination of flags, thus creating a file instead of opening a

Or perhaps to use it to escape syscall auditing if creation of files with
special flags would be monitored but directory creation is not?


DI Roman Fiedler
Safety & Security Department
Assistive Healthcare Information Technology

AIT Austrian Institute of Technology GmbH
Reininghausstraße 13/1 | 8020 Graz | Austria
T +43(0) 50550 2957 | M +43(0) 664 8561599 | F +43(0) 50550 2950 |

FN: 115980 i HG Wien  |  UID: ATU14703506

Download attachment "smime.p7s" of type "application/pkcs7-signature" (6344 bytes)

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.