Commit c21035a
rtapi: make harden_rt() rootless-safe
setrlimit(RLIMIT_RTPRIO, RLIM_INFINITY) requires CAP_SYS_RESOURCE,
which neither setuid root nor 'make setcap' (CAP_IPC_LOCK,
CAP_NET_ADMIN, CAP_SYS_RAWIO, CAP_SYS_NICE) grants by default. Under
rootless the call returns EPERM, which the previous code treated as
fatal -- harden_rt() returned -errno, makeApp() fell back to
SCHED_OTHER, and the SCHED_FIFO probe in rtapi_is_realtime() became
a lie.
Soften both setrlimit calls to best-effort: SCHED_FIFO scheduling
itself only needs CAP_SYS_NICE, which the cap set does grant; the
rlimit just bounds the achievable priority. Distros that want
unlimited RT priority can ship a /etc/security/limits.d entry, or
the operator can grant CAP_SYS_RESOURCE explicitly.
Also update the iopl() error message: 'sudo make setuid' is no
longer the only path, and the diagnostic should name the missing
capability (CAP_SYS_RAWIO).
Derived from Damian Wrobel's 2020 'Unify FIFO_SCHED between root and
non-root user' commit, ported onto hdiethelm's rtapi cleanup v2
structure.
Co-authored-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>1 parent 34863c9 commit c21035a
1 file changed
Lines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
886 | 886 | | |
887 | 887 | | |
888 | 888 | | |
889 | | - | |
| 889 | + | |
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
| |||
895 | 895 | | |
896 | 896 | | |
897 | 897 | | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
903 | 906 | | |
904 | | - | |
905 | 907 | | |
906 | 908 | | |
907 | 909 | | |
908 | 910 | | |
909 | 911 | | |
910 | | - | |
| 912 | + | |
911 | 913 | | |
912 | 914 | | |
913 | 915 | | |
| |||
0 commit comments