Rainer Weikusat
2024-05-23 20:44:06 UTC
or "Maybe, I'm full of it BUT I work for Google ... !"
I have program for executing another program with some fnctl-based file
locks held I've been using for almost 20 years. This program always
opens files with O_CREAT added to the mode so that, in case of multiple
concurrent calls of it and no previously existing file, one of these
calls creates the file and all others open it.
Further, I have a directory with the following permissions:
drwxrwx--T 6 root caca 4096 May 23 20:22 ca-CA/
as I want members of the caca group to be able to create files in this
directory but not remove files owned by root. Inside this directory,
there's a file with the following permissions:
-rw-r--r-- 1 caca caca 3 Jan 1 1970 serial
A shell script associated with that tries to acquire an R/W lock on this
file in order to serialize concurrent invocations of it. On Debian 12,
when running as root, this fails with EACCES. That's do to a suckurity
feature (supposed to make the system suck harder) documented as follows (proc(5)):
/proc/sys/fs/protected_regular (since Linux 4.19)
1 Don't allow O_CREAT open(2) on regular files that the caller doesn't
own in world-writable sticky directories, unless the regular file is
owned by the owner of the directory.
2 As for the value 1, but the restriction also applies to
group-writable sticky directories.
The intent of the above protections is similar to protected_fifos, but
allows an application to avoid writes to an attacker-controlled regular
file, where the application expected to create one.
and default value of this control knob is - for maxium suckurity because
Google says that's how it must be done and Google CANNOT be wrong!!! -
obviously 2.
Who told this hyperintelligent being that O_CREAT means "application
expected to create a file" AND NOT "create file if it doesn't exist
already", ie, the documented semantics?
GRRRR.
I have program for executing another program with some fnctl-based file
locks held I've been using for almost 20 years. This program always
opens files with O_CREAT added to the mode so that, in case of multiple
concurrent calls of it and no previously existing file, one of these
calls creates the file and all others open it.
Further, I have a directory with the following permissions:
drwxrwx--T 6 root caca 4096 May 23 20:22 ca-CA/
as I want members of the caca group to be able to create files in this
directory but not remove files owned by root. Inside this directory,
there's a file with the following permissions:
-rw-r--r-- 1 caca caca 3 Jan 1 1970 serial
A shell script associated with that tries to acquire an R/W lock on this
file in order to serialize concurrent invocations of it. On Debian 12,
when running as root, this fails with EACCES. That's do to a suckurity
feature (supposed to make the system suck harder) documented as follows (proc(5)):
/proc/sys/fs/protected_regular (since Linux 4.19)
1 Don't allow O_CREAT open(2) on regular files that the caller doesn't
own in world-writable sticky directories, unless the regular file is
owned by the owner of the directory.
2 As for the value 1, but the restriction also applies to
group-writable sticky directories.
The intent of the above protections is similar to protected_fifos, but
allows an application to avoid writes to an attacker-controlled regular
file, where the application expected to create one.
and default value of this control knob is - for maxium suckurity because
Google says that's how it must be done and Google CANNOT be wrong!!! -
obviously 2.
Who told this hyperintelligent being that O_CREAT means "application
expected to create a file" AND NOT "create file if it doesn't exist
already", ie, the documented semantics?
GRRRR.