75 Commits

Author SHA1 Message Date
Elliott Hughes
a1194cb636 Use ABI_STRING.
Bug: N/A
Test: builds
Change-Id: I5a9d2a6604887f1f0e9583086e012a086042b7df
2018-03-23 11:27:04 -07:00
George Burgess IV
8a4be2a6ae Merge "app_main: silence static analyzer warnings"
am: cf188f664a

Change-Id: Ibad16ec8fabb4edaaa832bc43505f81fefb10ec7
2017-07-12 02:54:24 +00:00
George Burgess IV
c29844d072 app_main: silence static analyzer warnings
This silences two warnings:

frameworks/base/cmds/app_process/app_main.cpp:238:11: warning: Potential
memory leak

frameworks/base/cmds/app_process/app_main.cpp:261:9: warning: Potential
memory leak

As the (existing) comment notes, we nuke argv later in main(), so these
copies are necessary. Since these args need to live for basically the
entire life of the process, it seems pointless to go out of our way to
free them.

Bug: 27101951
Test: mma. Static analyzer warnings are gone.
Change-Id: Icbfabfede9db909f6acb274b697cb6076c3fc11f
2017-07-11 17:28:15 -07:00
Martijn Coenen
b69ffdb207 Stop hwbinder threads from app_process.
To prevent it from hanging up.

Bug: 37500397
Bug: 34085250
Test: DismissDialogsInstrumentation test
Change-Id: Ia69f6a5676666bc9286272b82f242d7b1d0ee286
2017-04-19 16:40:49 -07:00
Josh Gao
92517e4c03 app_process: don't use PR_SET_NO_NEW_PRIVS.
selinux should provide equivalent protection, and this prevents
transitioning to a helper binary for crash dumping.

Bug: http://b/30705528
Change-Id: I64b05236931d418f268b193418e937ab6b0985e0
2017-01-17 13:55:20 -08:00
Andreas Gampe
2200e09736 App_process: Merge app_process and app_process__asan
Two birds with one stone: simplify the setup (including the modules
required in PRODUCT_PACKAGES) and work around a build system issue
wrt/ sanitized static libraries.

Bug: 33224213
Test: mmma frameworks/base/cmds/app_process && \
      mmma SANITIZE_TARGET=address SANITIZE_LITE=true \
      frameworks/base/cmds/app_process && \
      ls $OUT/system/bin/asanwrapper && \
      readelf -s $OUT/system/bin/app_process32 | grep asan && \
      readelf -s $OUT/system/bin/asan/app_process32 | grep asan && \

Change-Id: Ieff0ea9a2209cf74cf06f813087b55cb0bcc3896
2016-11-30 16:35:32 -08:00
Andreas Gampe
622f511f2f App_process: Clean up sanitized binaries
Clean up the definition of sanitized binaries. Clean up the
Android.mk to share values.

Bug: 33224213
Test: mmma SANITIZE_TARGET=address SANITIZE_LITE=true frameworks/base/cmds/app_process && ls $OUT/system/bin/asan
Change-Id: I70f8d95ff2ec6366fc0a7d252b91dce268186910
2016-11-30 09:46:09 -08:00
Glenn Kasten
827d0d76fb LOCAL_CLANG := true is now the default
Change-Id: I2f6a8c7f32cbf682c968a43d590d773ffb21e909
(cherry picked from commit 3a7510bcf6089d3ef768de7cf805ca783f0aac17)
2016-11-30 09:42:23 -08:00
Treehugger Robot
4a4a8f1555 Merge "app_process: Forward -cp/-classpath to ART." 2016-10-28 17:34:47 +00:00
Elliott Hughes
c08e32e0be Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I7180f1eb539ff8cbe33832d010775f053a922946
2016-10-07 15:57:17 -07:00
Igor Murashkin
4f66cb3f53 app_process: Forward -cp/-classpath to ART.
* No new functionality was added, this was already possible via
  -Djava.class.path=classpath
* However, this makes it a bit more compatible with other tools
  that use -cp to invoke the main class.
* Also update the benchmarks README for correct up-to-date vogar
  instructions.

Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/ParcelBenchmark.java
Bug: 31807538
Change-Id: Idb04600fed3dd955437ccac832617dcfd1b52b63
2016-10-03 11:08:42 -07:00
Narayan Kamath
5638991c82 app_main: failure to PR_SET_NO_NEW_PRIVS is always fatal.
Don't make allowances for older kernels. Kernels must handle this
properly since it is now a CTS requirement.

Also remove some unreachable return statements.

Change-Id: I280c4ed5e461d37672236747b5dbb7d1e97ecfec
2016-09-14 10:24:20 +01:00
Dmitriy Filchenko
7310cc4880 Remove unused includes.
BUG: 29824203

Change-Id: I795f8abe31575f70da263921c6ec13b73b24dc7b
2016-08-18 01:45:11 +00:00
Dimitry Ivanov
4c5281862f libsigchain: intercept bsd_signal on lp32
bsd_signal is a deprecated synonym for the signal. Nevertheless
there are apps and libraries calling this function.

libsigchain needs to intercept these calls and handle them the same
way it handles signal() call.

Bug: http://b/30562229
Test: readelf --dyn-sym app_process32 and check that bsd_signal is exported
      readelf --dyn-sym app_process64 and check that bsd_signal is not exported
Change-Id: Iec584070b42bc7fa43b114c0f884aff2db5a6858
2016-08-01 14:19:26 -07:00
Dmitriy Filchenko
f5b6e5590e Handle long process names correctly.
pthread_setname_np() expects 16 or fewer characters for the name argument. When the process name is longer, we should trim it.

Change-Id: I40be3a4212bdaab900c8eb30fa27aeeb7ed1b0d1
2016-07-18 16:03:05 -07:00
Dmitriy Filchenko
342c7dcd02 Remove calls to set_process_name.
BUG:29824203

Change-Id: I67a1eb350cf9ea28c554166986df8fc251b666eb
2016-07-12 15:44:55 -07:00
Dimitry Ivanov
6a850b3f11 zygote: Remove NativeLoader initialization step
This now done by art Runtime::Start()

Bug: http://b/28320913
Change-Id: Icf9b11954b732c9f953e02bba9ae52eb91117457
2016-04-27 10:22:09 -07:00
Dimitry Ivanov
efab1544d0 Renamed the function initialing nativeloader
Bug: http://b/27546414
Change-Id: Ia0b65540772ca4bd1cdab391973325b18cd278a0
(cherry picked from commit bf1082e9a1ae833718321ac58ab64e281d0e3614)
2016-03-17 11:16:32 -07:00
Nicolas Geoffray
1da1e5cd3b Fix ASAN builds after app_process change.
Bug:27245894

(cherry picked from commit 573895bbea7cf349d615606004cdb85ba2ca814d)

Change-Id: I1b879f23cd2bb49070cbfee40ae1b8a586a328dc
2016-02-26 13:36:20 +00:00
Dimitry Ivanov
204386e1c5 zygote to preload public native libraries
Preload public native libraries when starting a zygote
This lets other users of libnativeloader (like dex2oat)
avoid unnecessary cold loads of libandroid.so which could
take up to a second.

Bug: http://b/27245894

(cherry picked from commit b0824979be2653ba300382b52c1b1236fd44f0de)

Change-Id: I04a640c104dba5b585a59d63270e81b6c9ad6f7e
2016-02-26 10:25:06 +00:00
Sebastien Hertz
60a2716f72 am 3244dc22: am 677cd087: am e9de1b4c: am 9a010d0a: Merge "Allow debugging only for apps forked from zygote" into mnc-dev
* commit '3244dc229af4d4c8b764bf9ca1e108b5cd933d90':
  Allow debugging only for apps forked from zygote
2015-08-18 09:52:46 +00:00
Sebastien Hertz
7a09b8322c Allow debugging only for apps forked from zygote
When starting the runtime from app_process, we only pass JDWP options
if starting zygote. It prevents from opening a JDWP connection in
non-zygote programs while Android apps (forked from zygote) remain
debuggable.

Bug: 23050463
Change-Id: If8ea719063a65db4cdeed69a838b52e87b078b08
2015-08-10 20:39:13 +02:00
Christopher Ferris
7493793b2c am d9f60741: am bf30b4fd: Merge "Add libwilhelm to app_process." into mnc-dev
* commit 'd9f607417206552ecf48ba7a7f449321031619a7':
  Add libwilhelm to app_process.
2015-06-20 00:10:11 +00:00
Christopher Ferris
ad81791641 Add libwilhelm to app_process.
If an app exposes new/delete from a shared library, the libwilhelm
shared library can wind up using the new from the app shared library,
and the delete from libc++. It is completely legal for the app to
export new/delete in this way, so in order to avoid this situation,
preload libwilhelm in the zygote. This forces libwilhelm to always
resolve the new/delete from libc++.

This library cannot be added to android_runtime since libwilhelm
has a shared library which depends on android_runtime.

Bug: 21032018
Change-Id: Id89c196df62d98d62855a1421f397b75a7e990a9
2015-06-17 15:30:29 -07:00
Dan Albert
492253742a am 3a059d2d: am f35f66a8: Merge "Use new sanitizer option."
* commit '3a059d2d89dd87690ccf4081097d8d069bb7f3c4':
  Use new sanitizer option.
2015-06-16 21:45:32 +00:00
Dan Albert
f98dae5675 Use new sanitizer option.
Change-Id: Iabc46da2820f252f6cd8cef8a447064890f3a76d
2015-06-16 14:06:49 -07:00
Narayan Kamath
fbb32f6440 Better systrace slices for application startup.
This change adds three new timeslices :

- PostFork : As soon as possible after the app forks from the
  zygote. Can be used in conjunction with the system_server
  "Start proc:" event to derive an upper bound on fork() and
  zygote overhead.

- RuntimeInit & ActivityThreadMain for ZygoteInit#runtimeInit
  and ActivityThread#main.

ActivityThread#handleBindApplication and higher level functions
are already well instrumented in systrace. handleBindApplication
should occur immediately after ActivityThread#main.

Note that we use the Activity manager tag to make it easier to
correlate these new events with surrounding events (Start proc
and handleBindApplication) that are already using the AM tag.

bug: 21632700
Change-Id: Ibc01f1721f962c913f3c02a51763b6feb1eb6a4d
2015-06-16 12:06:31 +01:00
Evgenii Stepanov
5ca3afa296 Update asan/app_process.
Build both 32 and 64-bit versions and don't limit it to eng.

Change-Id: I5d6cc8005291100d5fe0f1385e8a0b4ba5f4d630
(cherry picked from commit e740b17d2400ed0db17d1f7fce4f052bbbf808ab)
2015-05-28 12:47:30 -07:00
Evgenii Stepanov
e740b17d24 Update asan/app_process.
Build both 32 and 64-bit versions and don't limit it to eng.

Change-Id: I5d6cc8005291100d5fe0f1385e8a0b4ba5f4d630
2015-05-07 10:55:59 -07:00
Dan Albert
b9f6b0eec3 Explicitly use clang.
This was implicitly enabled by using ASAN.

Change-Id: I562402a8191e2a3ab3eefd43860fbe7c58d441d8
2015-04-17 10:40:48 -07:00
Mark Salyzyn
fc737fb76c app_main missing include for sys/stat.h
app_main.c gets sys/stat.h inherited from
private/android_filesystem_config.h it should
not rely on this in the future. The intent is
to move fs_config function into libcutils and
thus deprecate any need for sys/stat.h in this
include file.

Bug: 19908228
Change-Id: I477b825e582742113f849aaa1df50c41e496b6f6
2015-04-01 16:02:32 +00:00
Douglas Leung
7e7c603182 Add mips64 support to app_process.
Change-Id: Ieb05a212606f02ebad119a0aea0ed92773ace214
2014-12-17 20:27:25 -08:00
Andreas Gampe
cfedceb8c1 Frameworks/base: Turn on -Wall -Werror in cmds
Fix small warnings, turn on -Wall -Werror.

Change-Id: Iab1f01a7c7ebd6ba832b75067c5e395f380a1b8b
2014-11-07 14:33:51 -08:00
Dmitriy Ivanov
a0d07d49b8 am 9be7db6e: am 952dd924: Merge "Switch to libsigchain.a"
* commit '9be7db6e3bc374efd9dcff744deab92148e20dbd':
  Switch to libsigchain.a
2014-10-21 03:29:46 +00:00
Dmitriy Ivanov
5ba317cee0 Switch to libsigchain.a
Use LOCAL_WHOLE_STATIC_LIBRARIES to instruct static linker
 to export symbols from the static library.

Change-Id: I465806dcffc777a682523f74ae6f7ab61aaa6962
2014-10-20 14:14:39 -07:00
Dmitriy Ivanov
7f05e9118b am d1e735ef: am ed583f5e: Merge "Link sigchain to main executable"
* commit 'd1e735ef547c1720aa5bb56a446afbb7a8652599':
  Link sigchain to main executable
2014-10-14 18:21:49 +00:00
Dmitriy Ivanov
96e0cfa721 Link sigchain to main executable
Also export necessary symbols to preempt calls from
 libart.so

Bug: 15345057
Bug: 15426766
Change-Id: If0b7f59a59824e30aa0c33dad76c7a44932180de
2014-10-09 15:03:07 -07:00
Jeff Brown
00c0cd4a24 Clean entire arg block when setting process name.
When Android processes fork from Zygote, we rewrite the command line
with a new name, eg. "system_server".  When we do this, we should
fill the entire block with zeros to remove corrupted argument
information that may otherwise remain in the /proc/<pid>/cmdline buffer
and be seen in tools and stack dumps.

Fixed an issue where VM options could be overwritten after setting
the nice name if the name was too long.

Bug: 17474152
Change-Id: Ie6cf9ed7752a04300a340e26cd6812bb35c59e1b
2014-09-11 14:19:52 -07:00
Alex Light
55471dcd0f Change /dalvik-cache to be owned by root.
Bug: 16875245

(cherry picked from commit 79bf4007f559e194205f632b23d2bfb6f8d1e7ba)

Change-Id: I29a70215a2207bc4e0db02ab751d32a68edf4b66
2014-08-28 17:02:37 -07:00
Alex Light
79bf4007f5 Change /dalvik-cache to be owned by root.
Bug: 16875245

Change-Id: I29a70215a2207bc4e0db02ab751d32a68edf4b66
2014-08-28 11:34:50 -07:00
Yongqin Liu
559484ed6a app_process: change app_process a symlink of primary version
Change app_process to be a symlink to the primary version
and have app_process32/app_process64 be the 32-bit/64-bit
versions respectively.

This will make it possible to use the primary zygote for
am/pm commands and other scripts that use app_process and
don't need a specific zygote.

Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Change-Id: Ibef545994eb95ddc82101c95df613ad1d06345e6
2014-05-14 18:48:42 +01:00
Narayan Kamath
d6183204e4 Fix x86 build in app_process.
Look for __i386__ and not __x86__.

(cherry picked from commit 47d526217b3fd0d17ba751c66d25cfaf1c6ed7cd)

Change-Id: I848ba351c378e59ab6744ca1983ae4463ae75ba4
2014-05-01 11:27:49 +01:00
Narayan Kamath
973cdeed8e Create arch specific cache dirs during zygote startup.
The runtime expects them to exist before it's launched.
The boot image / art files are created during the first
zygote launch.

(cherry picked from commit da738713e4e2120a324e8ab6fd11aa0e54a3c66e)

Change-Id: I7472aa25c16a1cf95791af2bdf80ed0d73123872
2014-05-01 11:26:49 +01:00
Nick Kralevich
195c73c9b2 Set NO_NEW_PRIVS on zygote init
When app_process/zygote starts, make sure PR_SET_NO_NEW_PRIVS is set.
This prevents zygote spawned apps from acquiring new privileges
on exec.

In particular, this allows the CTS test
android.os.cts.SecurityFeaturesTest#testNoNewPrivs() to pass if ART is set
as the default runtime.

Change-Id: I81139cda999c7b1430242561aad28f566e9b6da0
2014-04-29 15:10:58 -07:00
Elliott Hughes
6bd762289b Fix a typo in an assertion.
Change-Id: I3e97bb3cb8070c0ec0c6b97769f1da3e7b4ef8f5
2014-04-23 16:54:33 -07:00
Narayan Kamath
90c75cf02e Don't compare String8s to NULL.
Use String8::isEmpty instead. Note that this code path is hit
only if the zygote calls ::exit, and that never happens unless
the VM invocation fails.

Change-Id: I0e7d3a86a79b12b2174ca3bf0dbe1904e33c041a
2014-04-12 12:25:50 +01:00
Narayan Kamath
d35d3e5d39 Dual zygote cleanup.
- Use different process names for the 32 / 64 bit zygote.
- Pass command line arguments correctly. The first unmatched
  argument must be passed through to the java main class.

Change-Id: I952ebbdbba941f118d992354b9bd0ada2dade417
2014-04-10 12:15:39 +01:00
Narayan Kamath
c41638cb75 Make zygotes aware of their supported ABIs.
Query system properties for the list of ABIs and pass
it as a command line argument to ZygoteInit.

Also add a new Zygote command that returns this list of
ABIs to peers.

Change-Id: I68034c6f63fa626911122579a011a0a25a8cda94
2014-04-09 13:41:15 +01:00
Narayan Kamath
22ec1eefa4 Clean up argc / argv processing for runtime args.
- Make copies of argc, argv before argv is potentially
  overwritten with the process name.
- Allow multiple command line arguments to be passed to
  ZygoteInit (this is required for some of the 64 bit
  zygote work).
- Add an explanatory comment about how these argments
  are processed.

Change-Id: I752be69c5c0f97ed17d1a3dded19f46ee00929b0
2014-04-09 13:39:41 +01:00
Narayan Kamath
a23fcd7be8 Remove ProcessState::mArgc,mArgV,mArgLen
These look like historical oddities, and weren't really being
used for anything useful.

Process:setArgV0 was being called by android.util.Process, but
that functionality can be moved directly into the implementation
of that class.

bug: 13647418

Change-Id: I216c8f8a4c065f0cf3a61f19f9e32decd26f93f6
2014-04-03 12:29:07 +00:00