2020-02-27 10:39:43

by Russell Coker

[permalink] [raw]
Subject: /run/systemd/inaccessible

allow systemd_logind_t init_var_run_t:chr_file write;

audit2allow shows me that the above is attempted on Debian/Unstable. What's
this inaccessible directory about anyway?

# ls -lZ /run/systemd/inaccessible
total 0
b---------. 1 root root system_u:object_r:init_var_run_t:s0 0, 0 Feb 27 13:36
blk
c---------. 1 root root system_u:object_r:init_var_run_t:s0 0, 0 Feb 27 13:36
chr
d---------. 2 root root system_u:object_r:init_var_run_t:s0 40 Feb 27 13:36
dir
p---------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
fifo
----------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
reg
s---------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
sock

--
My Main Blog http://etbe.coker.com.au/
My Documents Blog http://doc.coker.com.au/


2020-02-27 12:22:59

by Dominick Grift

[permalink] [raw]
Subject: Re: /run/systemd/inaccessible

Russell Coker <[email protected]> writes:

> allow systemd_logind_t init_var_run_t:chr_file write;
>
> audit2allow shows me that the above is attempted on Debian/Unstable. What's
> this inaccessible directory about anyway?

systemd-userruntimedir (245) now also creates it in /run/user/%{USERID}

probably used for InaccessiblePath= directive but I am not sure.

>
> # ls -lZ /run/systemd/inaccessible
> total 0
> b---------. 1 root root system_u:object_r:init_var_run_t:s0 0, 0 Feb 27 13:36
> blk
> c---------. 1 root root system_u:object_r:init_var_run_t:s0 0, 0 Feb 27 13:36
> chr
> d---------. 2 root root system_u:object_r:init_var_run_t:s0 40 Feb 27 13:36
> dir
> p---------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
> fifo
> ----------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
> reg
> s---------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
> sock

--
Key fingerprint = FCD2 3660 5D6B 9D27 7FC6 E0FF DA7E 521F 10F6 4098
https://sks-keyservers.net/pks/lookup?op=get&search=0xDA7E521F10F64098
Dominick Grift

2020-02-27 18:14:04

by Topi Miettinen

[permalink] [raw]
Subject: Re: /run/systemd/inaccessible

On 27.2.2020 14.20, Dominick Grift wrote:
> Russell Coker <[email protected]> writes:
>
>> allow systemd_logind_t init_var_run_t:chr_file write;
>>
>> audit2allow shows me that the above is attempted on Debian/Unstable. What's
>> this inaccessible directory about anyway?
>
> systemd-userruntimedir (245) now also creates it in /run/user/%{USERID}

The relevant code has this comment:

/* Set up inaccessible nodes now so they're available if we decide to
use them with user namespaces. */

> probably used for InaccessiblePath= directive but I am not sure.

Yes, these are bind mounted over the path which is wanted inaccessible.
Perhaps this could be improved by giving them a dedicated label and then
some new TE rules could prevent anything other than PID1 from managing
them. Now if a service has CAP_SYS_ADMIN and is not blocked by seccomp
filters from using mount and umount system calls, it could dismantle the
bind mount.

-Topi

>>
>> # ls -lZ /run/systemd/inaccessible
>> total 0
>> b---------. 1 root root system_u:object_r:init_var_run_t:s0 0, 0 Feb 27 13:36
>> blk
>> c---------. 1 root root system_u:object_r:init_var_run_t:s0 0, 0 Feb 27 13:36
>> chr
>> d---------. 2 root root system_u:object_r:init_var_run_t:s0 40 Feb 27 13:36
>> dir
>> p---------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
>> fifo
>> ----------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
>> reg
>> s---------. 1 root root system_u:object_r:init_var_run_t:s0 0 Feb 27 13:36
>> sock
>