Messages in this thread | | | Date | Sat, 21 Jul 2012 01:54:36 +0530 | Subject | vfork() / clone() with pthreads / setuid | From | Vishal K <> |
| |
Hello Kernel experts,
From http://developers.sun.com/solaris/articles/subprocess/subprocess.html , I am curious to know if the following is already addressed in linux kernel for vfork() / clone() calls.
The vfork(2) system call was also adopted in the Solaris OS. Much later, however, when multithreading (MT) became available and widely used it was discovered that vfork() may introduce a new problem when the application has multiple threads running: deadlock. The deadlock can happen due to the dynamic linker ld.so.1 involvement in resolving the necessary symbols. Particularly, if the child process calls an external function (such as exec()), the dynamic linker may be invoked to resolve the Procedure Linkage Table (PLT) entry, for which the dynamic linker will acquire a mutex lock. This lock may already be held by a different thread in the parent process. If this happens it will create a deadlock between the parent and child processes, because no thread in the parent can run until the child has called exec() or exit(). As a result, both the parent and the child processes will hang.
Also, is it allowed to call setuid() after a vfork() or a clone() before doing execv() so that the executed command can be run as a different user?
I realize this may not be the right forum for such queries, but looks like this is not available anywhere.
Regards, Kernel Rocks.
| |