diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-24 18:48:49 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:49:45 +0200 |
commit | 30a3ebbb0b6094fca91baa056d1904a564c5d981 (patch) | |
tree | d3b3fc8b4a486d227fb078cb598596239bb5fae6 /src | |
parent | a09384dde54cbb644b3c414ba8dec15112497cab (diff) |
process-util: allow rename_process() only in the main thread
We make assumptions about the comm name we set via PR_SET_NAME: that it
would reflect the process name, but that's only the case for the main
thread. Moreover, we cache the mmap() region without locking.
Let's hence be safe rather than sorry and support all this only in the
main thread.
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/process-util.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index e1b2664f3..5a00fca83 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -298,6 +298,11 @@ int rename_process(const char name[]) { if (isempty(name)) return -EINVAL; /* let's not confuse users unnecessarily with an empty name */ + if (!is_main_thread()) + return -EPERM; /* Let's not allow setting the process name from other threads than the main one, as we + * cache things without locking, and we make assumptions that PR_SET_NAME sets the + * process name that isn't correct on any other threads */ + l = strlen(name); /* First step, change the comm field. */ |