selinux/libselinux
Christian Göttsche 7e979b56fd libselinux: restorecon: pin file to avoid TOCTOU issues
Pin the file to operate on in restorecon_sb() to prevent symlink attacks
in between the label database lookup, the current context query and the
final context write.  Also don't use the file information from
fts_read(3), which might also be out of sync.

Due to querying file information twice, one in fts_read(3) needed for
the cross device check and one on the pinned file descriptor for the
database lookup, there is a slight slowdown:

    [current]
    Time (mean ± σ):     14.456 s ±  0.306 s    [User: 45.863 s, System: 4.463 s]
    Range (min … max):   14.275 s … 15.294 s    10 runs

    [changed]
    Time (mean ± σ):     15.843 s ±  0.045 s    [User: 46.274 s, System: 9.495 s]
    Range (min … max):   15.787 s … 15.916 s    10 runs

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-05-16 10:21:47 -04:00
..
include selinux_restorecon: introduce SELINUX_RESTORECON_COUNT_ERRORS 2022-05-04 10:31:42 +02:00
man libselinux: emulate O_PATH support in fgetfilecon/fsetfilecon 2022-05-16 10:21:47 -04:00
src libselinux: restorecon: pin file to avoid TOCTOU issues 2022-05-16 10:21:47 -04:00
utils libselinux/utils: check for valid contexts to improve error causes 2022-04-12 13:09:27 -04:00
LICENSE initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
Makefile libselinux: use PCRE2 by default 2021-12-09 11:07:00 -05:00
VERSION Update VERSIONs to 3.4-rc3 for release. 2022-05-04 19:20:37 +02:00