diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-10-21 22:58:25 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-10-22 17:51:26 +0200 |
commit | 4946dd4197efee693432b3ddff56f30205d3bdfd (patch) | |
tree | a9ef5d79b2a092cac29246487ed81c9ccb272ec2 /man/vconsole.conf.xml | |
parent | fs-util: always call label post ops in xopenat_full(), in both success and er... (diff) | |
download | systemd-4946dd4197efee693432b3ddff56f30205d3bdfd.tar.xz systemd-4946dd4197efee693432b3ddff56f30205d3bdfd.zip |
fs-util: tweak how openat_report_new() operates when O_CREAT is used on a dangling symlink
One of the big mistakes of Linux is that when you create a file with
open() and O_CREAT and the file already exists as dangling symlink that
the symlink will be followed and the file created that it points to.
This has resulted in many vulnerabilities, and triggered the creation of
the O_MOFOLLOW flag, addressing the problem.
O_NOFOLLOW is less than ideal in many ways, but in particular one: when
actually creating a file it makes sense to set, because it is a problem
to follow final symlinks in that case. But if the file is already
existing, it actually does make sense to follow the symlinks. With
openat_report_new() we distinguish these two cases anyway (the whole
function exists only to distinguish the create and the exists-already
case after all), hence let's do something about this: let's simply never
create files "through symlinks".
This can be implemented very easily: just pass O_NOFOLLOW to the 2nd
openat() call, where we actually create files.
And then basically remove 0dd82dab91eaac5e7b17bd5e9a1e07c6d2b78dca
again, because we don't need to care anymore, we already will see ELOOP
when we touch a symlink.
Note that this change means that openat_report_new() will thus start to
deviate from plain openat() behaviour in this one small detail: when
actually creating files we will *never* follow the symlink. That should
be a systematic improvement of security.
Fixes: #34088
Diffstat (limited to 'man/vconsole.conf.xml')
0 files changed, 0 insertions, 0 deletions