Commit graph

23 commits

Author SHA1 Message Date
Chih-Hung Hsieh
62e3a078aa Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I84effbdfa1b9b39328a909b7f70fe17e7ee316c8
2016-05-03 12:08:05 -07:00
Tom Cherry
8352475c75 Replace snprintf() with __libc_format_buffer()
If snprintf() is called from the linker, it may erroneously return a
null string.  The libc internal __libc_format_buffer() does not have
this problem, so it is now used instead.

Bug: 26756577

Change-Id: I37a97e27f59b3c0a087f54a6603cc3aff7f07522
2016-01-26 23:51:01 +00:00
Tom Cherry
e97ce31fe7 Revert "system_properties.cpp: special case ro.* properties"
This reverts commit c5fd81ab25.

Bug: 26416032

Change-Id: Id2d6761fdf55efa28c0b08b597daaa5cd381d758
2016-01-06 19:13:54 +00:00
Nick Kralevich
c5fd81ab25 system_properties.cpp: special case ro.* properties
Currently, reads of ro.* properties are treated differently than
writes of ro.* properties. When writing an ro.* property, we ignore
the "ro." portion of the property, and base the security decision
on the label of the remaining portion.

See e7a9e52740/init/property_service.cpp
line 120-126

For example, for writing, the label associated with
"ro.build.fingerprint" comes from the /property_contexts file
entry:

  # ro.build.fingerprint is either set in /system/build.prop, or is
  # set at runtime by system_server.
  build.fingerprint       u:object_r:fingerprint_prop:s0

However, we fail to follow this same special case when sorting
properties into files. Instead, ro.build.fingerprint is assigned
u:object_r:default_prop:s0 instead of u:object_r:fingerprint_prop:s0

Ignore the "ro." portion when sorting properties into files.
This will make reads and writes of properties use the same label.

Bug: 21852512
Change-Id: Ie88ffc6b78b31fc8ddf370ae27c218546fb25a83
2016-01-05 16:30:17 -08:00
Tom Cherry
b417169d80 Reset access to system properties on reinitialization
Treat subsequent calls to __system_properties_init() as a
reinitialization of system properties and revoke access to prop files
that have been previously mapped but that the process's current context
does not have access to.  Additionally reset the no_access_ flag in
case permissions have loosened and previously unaccessible files can now
be accessed.

This is meant to work around an issue that setcon() does not revoke
mmap() mappings, so we must manually revoke them after a successful
setcon() call.

Bug 26114086

Change-Id: I4d690abb6817283ca64ac26ea4c1dad398a98fbc
2015-12-11 11:16:21 -08:00
Tom Cherry
21eadee6e9 Do not create prop files for ctl.* properties
Change-Id: Ia6660c68c9e0cb89938751dbc0747ee038394778
2015-12-04 15:55:32 -08:00
Tom Cherry
6ed51c0e85 add checks for initialization for system properties
If a __system_property* function is called before
__system_properties_init() then the app will will abort.  This commit
returns either an error code or a safe return value instead.

Bug 26027140

Change-Id: I95ffd143e9563658ab67a397991e84fb4c46ab77
2015-12-04 13:26:47 -08:00
Tom Cherry
845e24a05e Remove c++14'isms from system_properties
Change-Id: If78e7d2770e8f8321f0d1824c3c52f93820dd325
2015-12-03 15:40:23 -08:00
Tom Cherry
49a309ff6a Separate properties by selabel
The purpose of this change is to add read access control to the property
space.

In the current design, a process either has access to the single
/dev/__properties__ file and therefore all properties that it contains
or it has access to no properties.  This change separates properties
into multiple property files based on their selabel, which allows
creation of sepolicies that allow read access of only specific sets of
properties to specific domains.

Bug 21852512

Change-Id: Ice265db79201ca811c6b6cf6d851703f53224f03
2015-12-02 15:17:03 -08:00
Tom Cherry
926ebe1094 Refactor prop_area into a class
Bug 21852512

Change-Id: I432bf592f1a71a046c32616fc334ad77c220f0ca
2015-11-09 17:22:44 -08:00
Mark Salyzyn
bfd65279a5 bionic: add __system_property_area_serial()
Adds a new _internal_ function. Provide a global serial number to
support more efficient private caching algorithms. This allows
to skip re-running the __system_property_find() call on misses until
there is a global change in the properties. This call is a read
barrier, the property data to be read following this call will be
read sequentially and up to date.

Bug: 19544788
Change-Id: I58e6a92baa0f3e8e7b9ec79b10af6d56407dab48
2015-04-27 07:44:03 -07:00
Yabin Cui
b8ce474217 Switch system_properties.cpp from bionic atomic operations to stdatomic.
Bug: 17177189
Change-Id: I42e05ad1c490cc7a8040138151afc0ee72a9b63f
2015-02-24 10:41:53 -08:00
Elliott Hughes
0dc39f9952 Fix a couple more cases of missing CLOEXEC.
The debuggerd case can probably never happen, because you're crashing at this
point anyway. The system property one seems possible though.

Change-Id: Idba6a4f1d68587ec5b320d1e25f0b6a987ea32a0
2014-09-22 17:43:09 -07:00
Elliott Hughes
f73183f1a3 More cases where libc should use O_CLOEXEC.
Change-Id: Idfa111aeebc5deca2399dae919e8b72eb54c23c0
2014-08-26 16:20:59 -07:00
Hans Boehm
1e8587a479 Work around atomic_load(const T*) issues.
Bug:17067219
Change-Id: I78e753bcf03464f5f05c3f37e394f2727d282589
2014-08-19 14:50:54 -07:00
Hans Boehm
30214b901e Add memory ordering constraint, convert to C11 atomics
Add an ordering constraint/fence to __system_property_serial.
This slows down a read on a Nexus 5 from about 50 to about 70 ns,
but avoids the possibility of seeing an inconsistent property value.
Use C11 atomic operations where easy and appropriate.
This code remains not fully C++11 memory model conformant, but
I would now expect the generated code to now be correct with current compilers.

Bug:14970171
Change-Id: I0891ff1d0f914ae5c3857e3d76b6a7c8a4a07d83
2014-08-08 11:34:25 -07:00
Christopher Ferris
03eebcb6e8 Move common macros into bionic_macros.h.
Bug: 15590152
Change-Id: I730636613ef3653f68c5ab1d43b53beaf8e0dc25
2014-06-18 14:23:46 -07:00
Elliott Hughes
d5ed63a6a8 Hide most of the private futex functions.
Also hide part of the system properties compatibility code, since
we needed to touch that to keep it building.

I'll remove __futex_syscall4 and futex in a later patch.

Bug: 11156955
Change-Id: Ibbf42414c5bb07fb9f1c4a169922844778e4eeae
2014-05-21 18:30:00 -07:00
Elliott Hughes
3e786987b5 Remove the unused __system_property_wait.
This isn't declared in any header file.

Bug: 14970171
Change-Id: Ib9fce61343dfb6b6ccd7e1430e1a6e34e4e869df
2014-05-14 17:02:09 -07:00
Elliott Hughes
8eac9af24e Bring in google3-style DISALLOW_* macros.
I've been meaning to do this for a very long time...

Change-Id: Ia8c16eee7c026c3c9505399948485fb778fb0152
2014-05-09 19:12:08 -07:00
jiaguo
879d330499 property: fix getting dirty serial value
__system_property_serial just returned serial value without
checking if it is dirty, so check and wait until serial
value is not dirty before return

Change-Id: If485b6251b5555b004912c66c7c2cb455a7fdbdc
Signed-off-by: jiaguo <jiaguo@marvell.com>
2014-03-13 12:42:52 -07:00
Narayan Kamath
37e9570bce Fix 64-bit build.
A warning about signed vs unsigned comparison was converted
into an error here :

 ...
 struct stat st;
 if (st.st_size > sizeof(prop_area) {
 ...

st_size is either an off64_t, which is a signed type. It's
worth investigating why this didn't trigger a warning on 32 bit,
where it's signed as well.

Change-Id: Ib2622bd5c444ddcfa7fb2141f00332cbb4a0818b
2014-02-24 11:05:02 +00:00
Narayan Kamath
c9ae21a5c3 Move system_properties over to C++.
This change constitutes the minimum amount of
work required to move the code over to C++, address
compiler warnings, and to make it const correct and
idiomatic (within the constraints of being called
from C code).

bug: 13058886

Change-Id: Ic78cf91b7c8e8f07b4ab0781333a9e243763298c
2014-02-24 10:45:35 +00:00
Renamed from libc/bionic/system_properties.c (Browse further)