Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Threads run at default priority #4

Open
ghost opened this issue Oct 23, 2021 · 0 comments
Open

Linux: Threads run at default priority #4

ghost opened this issue Oct 23, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 23, 2021

In the early days of development, Stargate engine ran as setuid or setcap and was able to give it's worker threads a high priority. Fast forward a few years, and security engineers have managed to ruin everything, as they often do. Specifically, the "problem" is that Stargate UI is written in Python, and manages the engine process which is written in C and wants elevated scheduler priority. Some highly overpaid security engineer concluded that only script kiddies would write a Python script that invokes a binary that wants to run with elevated permissions, and decided the best way to deal with this was to kill the process before it can even begin to execute.

Apparently compiling a binary with #include <sched.h> and then either giving the executable or the user permissions to change the scheduler is enough to trigger this behavior. Running the same executable from a terminal by hand will work, and will be able to change the scheduling, it's only invoking it from Python that is problematic.

Which left the following choices:

  1. Don't #include <sched.h>, and don't attempt to modify the priority. This is what is currently happening, and Stargate is so performant without any scheduler priority bump that it's not a problem.
  2. RtKit: Unfortunately, this is a useless solution for DAW work because of this
  3. Create some kind of daemon to manage subprocesses and thread priority ourselves. Because nobody would ever question the decision to run a daemon as root 🙄 . But this adds a huge amount of complexity and actual real security risks, and quite frankly it's silly to run a daemon at all times for a user application.

In conclusion:

  1. The lack of scheduler optimizations is very unlikely to encumber your ability to make music
  2. If it bothers you, learn that it shouldn't , or else complain to your distro + upstream security packages
@ghost ghost pinned this issue Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants