linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* openat, mkdirat, and TOCTOU for directory creation
@ 2021-02-27 14:27 Drew DeVault
  2021-02-27 17:58 ` Aleksa Sarai
  0 siblings, 1 reply; 3+ messages in thread
From: Drew DeVault @ 2021-02-27 14:27 UTC (permalink / raw)
  To: linux-fsdevel

Hiya! I'm looking into the mkdirat and openat syscalls, and I noticed
that there's no means of implementing TOCTOU (time-of-check to
time-of-use, a technique for preventing race conditions) on directory
creation.

To create a directory and obtain a dirfd for it, you have to (1)
mkdirat, then (2) openat with O_DIRECTORY, and if the directory is
removed in between, the latter will fail.

One possibly straightforward solution is to support openat with the
O_DIRECTORY and O_CREAT flags specified.

The present behavior of this flag combination is to create a file and
return ENOTDIR. The appropriate behavior is probably to create a
directory as proposed, or, at a minimum, to return EINVAL and not create
the file.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-27 20:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-27 14:27 openat, mkdirat, and TOCTOU for directory creation Drew DeVault
2021-02-27 17:58 ` Aleksa Sarai
2021-02-27 20:03   ` Drew DeVault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).