oss-sec mailing list archives

Re: open(2) with side effects


From: Stephane Chazelas <stephane.chazelas () gmail com>
Date: Thu, 23 Apr 2015 15:16:23 +0100

2015-04-23 15:08:43 +0200, Florian Weimer:
How common are file names on Linux which, when just opened and closed
(maybe with fstat or fgetattr inbetween), trigger side effects, such as
tape rewind?
[...]

Depends what you mean by side effect.

named pipes come to mind.

If a process is blocked on open() with O_RDONLY or O_WRONLY on a
named pipe, then when another process comes along and does the
symmetric (O_WRONLY or O_RDONLY) open(), the first process is
unblocked, and when you close() it, the other process will see
eof() on the fd or get a SIGPIPE if it writes...

Opening /dev/ptmx causes a new pts to be allocated. I'd expect
many other devices to allocate something upon an open.

Opening any file gets you closer to the limit of number of open
files.

Opening a file prevents its disk space from being reclaimed upon
the last unlink...

-- 
Stephane


Current thread: