Do not close all file descriptors 60/297960/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 29 Aug 2023 06:53:57 +0000 (15:53 +0900)
committerHwanKyu Jhun <h.jhun@samsung.com>
Wed, 30 Aug 2023 06:35:58 +0000 (06:35 +0000)
When the loader fails to find the main function, it tries to execute
an application using execv(). Before calling execv(), the loader closes
all opened file descriptors. Unfortunately, the loader can have crashed
by that. To avoid crash issues, this patch removes calling CloseAllFds().

Change-Id: I902d2f73ae30dc63e4d82599da6c1ced436e3920
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/app-defined-loader/app-defined-loader.cc
src/launchpad-loader/launchpad_loader.cc

index 57e7ffd..a135dc7 100644 (file)
@@ -183,7 +183,6 @@ class AppDefinedLoader {
           argv_[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
     } else {
       SECURE_LOGD("[candidate] Exec application (%s)", argv_[0]);
           argv_[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
     } else {
       SECURE_LOGD("[candidate] Exec application (%s)", argv_[0]);
-      launchpad::Util::CloseAllFds();
       if (!libdir.empty())
         setenv("LD_LIBRARY_PATH", libdir.c_str(), 1);
       unsetenv("AUL_LOADER_INIT");
       if (!libdir.empty())
         setenv("LD_LIBRARY_PATH", libdir.c_str(), 1);
       unsetenv("AUL_LOADER_INIT");
index cc62aa1..83cb8e3 100644 (file)
@@ -265,7 +265,6 @@ int LaunchpadLoader::DoExec(int argc, char** argv, const std::string& lib_dir) {
     SECURE_LOGE("access() is failed. path(%s), errno(%d)", argv[0], errno);
 
   SECURE_LOGD("Execute application. path(%s)", argv[0]);
     SECURE_LOGE("access() is failed. path(%s), errno(%d)", argv[0], errno);
 
   SECURE_LOGD("Execute application. path(%s)", argv[0]);
-  Util::CloseAllFds();
   if (!lib_dir.empty())
     setenv("LD_LIBRARY_PATH", lib_dir.c_str(), 1);
 
   if (!lib_dir.empty())
     setenv("LD_LIBRARY_PATH", lib_dir.c_str(), 1);