From: Lennart Poettering Date: Sun, 24 Dec 2017 17:48:49 +0000 (+0100) Subject: process-util: allow rename_process() only in the main thread X-Git-Tag: v237~173^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1096bb8a9e4a54bd9b2b1ce81533490d3ee9ecd0;p=platform%2Fupstream%2Fsystemd.git 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. --- diff --git a/src/basic/process-util.c b/src/basic/process-util.c index f91e2a4..2516730 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -297,6 +297,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. */