Remove unnecessary privilege change codes (Bypass seteuid(0) when the calling process is root)
While MIC-building a Tizen image, /usr/bin/tpk-backend with libgum calls gum_utils_gain_privileges() and is crashed.
void gum_utils_gain_privileges ()
{
if (seteuid(0)) WARN ("seteuid() failed");
}
It is found that seteuid(0) system calls with created threads
result in Segmentation Fault (SIGSEGV) in qemu-arm 2.7 and even in up-to-date qemu-arm 2.9
void *thread_main(void *);
int main(void) {
int status;
pthread_t thread;
pthread_create(&thread, NULL, &thread_main, NULL); <-- After creating a thread
sleep(1);
seteuid(0); <-- Call seteuid(0)
pthread_join(thread, (void **)&status);
return 0;
}
void *thread_main(void *arg) {
printf ("Thread.\n");
pause();
}
$) armv7l-tizen-linux-gnueabi-c++ -static -o test test.cc -lpthread
$) qemu-arm test
Segmentation fault (core dumped)
It seems a kind of QEMU bug.
When this patch (https://bugs.launchpad.net/qemu/+bug/1594394) is applied to QEMU 2.9, the problem is resolved.
To avoid the crash during MIC build without the qemu patch, this workaround patch needs to be submitted.
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I59a3d37a43864e0f4147c8088fe21db3ad692df5
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>