Commit graph

42 commits

Author SHA1 Message Date
Dennis Shen
3d1ce8c831 Revert "system properties: doubling the shared file size to 256Kb"
This reverts commit 46cce48995.

Reason for revert: 

Will put a change behind flags to bump storage to 1Mb for internal build only. AOSP code does not need to be changed. The change will be only made to git_main.

Change-Id: If3484d0e56f4c3d8fc729f55744c2d8ebdd13b11
2024-01-04 14:18:38 +00:00
Dennis Shen
46cce48995 system properties: doubling the shared file size to 256Kb
While aconfig flag storage is being migrated to its own dedicated
storage, we need to provide some relief to the current flag users which
are running into storage capacity limit of system property. Currently
system property by default allocates a file of 128Kb for each storage
node. Bump it to 256Kb for now.

Bug: b/316037066
Change-Id: I8b0b58733f362c3789ec92ae09ee589c7c1b72c6
2023-12-18 14:02:21 +00:00
Nate Myren
0ab0615f8c Move __system_properties_reload to LIBC from LIBC_PLATFORM
The zygote cannot have visiblity to LIBC_PLATFORM methods. Therefore,
move __system_properties_reload to LIBC, and rename it
__system_properties_zygote_reload, and indicate in comments that it
should not be used by non-zygote apps

Bug: 291814949
Test: atest CtsBionicRootTestCases
Change-Id: Iee8fa0c76b740543c05a433393f2f4bef36d6d3d
2023-10-25 17:41:33 -07:00
Nate Myren
b8c87b14b0 Write appcompat_override system properties
Create a second set of system properties, that can be overlaid over the
real ones if necessary, for appcompat purposes.

Bug: 291814949
Ignore-AOSP-First: Aosp -> internal merge conflict
Test: manual, treehugger, system_properties_test

Change-Id: I541d3658cab7753c16970957c6ab4fc8bd68d8f3
Merged-In: I884a78b67679c1f0b90a6c0159b17ab007f8cc60
2023-10-19 13:35:57 -07:00
Elliott Hughes
30088848fc Consistent qualifier ordering.
Change our handful of `constexpr static`s to the much more common
`static constexpr`. It's easier to "follow existing style" when there
aren't two existing styles to copy from, and all else being equal,
"majority wins" :-)

Test: treehugger
Change-Id: Ifbf0f62ab84c9450bf9c2e49e96915c126fd20c4
2023-09-14 18:36:55 +00:00
Elliott Hughes
141b917018 Switch to libbase SilentDeathTest.
Bug: http://b/184955378
Test: treehugger
Change-Id: Ie0849224074da92203340a741a86a24a4a3702c2
2021-04-12 10:01:20 -07:00
Raman Tenneti
b481a2e743 Revert "Revert "Make system property reads wait-free""
This reverts commit de39d9242a.

Reason for revert: This revert is not needed

Change-Id: I34af8e5d75c724f6c4066fafbfc6bc7d58377601
2019-11-12 20:41:55 +00:00
Raman Tenneti
de39d9242a Revert "Make system property reads wait-free"
This reverts commit 0cf90556de.

Reason for revert: Device boot failures - 144355953

Change-Id: Icd4fc8c7a1d06d688a6d37e6f1c1aa45563f711b
2019-11-12 18:24:06 +00:00
Daniel Colascione
0cf90556de Make system property reads wait-free
Right now, when we read a system property, we first (assuming we've
already looked up the property's prop_info) read the property's serial
number; if we find that the low bit (the dirty bit) in the serial
number is set, we futex-wait for that serial number to become
non-dirty. By doing so, we spare readers from seeing partially-updated
property values if they race with the property service's non-atomic
memcpy to the property value slot. (The futex-wait here isn't
essential to the algorithm: spinning while dirty would suffice,
although it'd be somewhat less efficient.)

The problem with this approach is that readers can wait on the
property service process, potentially causing delays due to scheduling
variance. Property reads are not guaranteed to complete in finite time
right now.

This change makes property reads wait-free and ensures that they
complete in finite time in all cases. In the new approach, we prevent
value tearing by backing up each property we're about to modify and
directing readers to the backup copy if they try to read a property
with the dirty bit set.

(The wait freedom is limited to the case of readers racing against
*one* property update. A writer can still delay readers by rapidly
updating a property --- but after this change, readers can't hang due
to PID 1 scheduling delays.)

I considered adding explicit atomic access to short property values,
but between binary compatibility with the existing property database
and the need to carefully handle transitions of property values
between "short" (compatible with atomics) and "long" (incompatible
with atomics) length domains, I figured the complexity wasn't worth it
and that making property reads wait-free would be adequate.

Test: boots
Bug: 143561649
Change-Id: Ifd3108aedba5a4b157b66af6ca0a4ed084bd5982
2019-11-11 11:17:00 -08:00
Elliott Hughes
bcaa454d32 bionic tests: use GTEST_SKIP.
Also be a bit more to the point in our messages, focusing on "why" not
"what".

Test: ran tests
Change-Id: I297806c7a102bd52602dcd2fcf7a2cd34aba3a11
2019-03-12 10:26:39 -07:00
Mark Salyzyn
ba1a723ad1 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-11-14 15:46:49 -08:00
Tom Cherry
ee8e3dd67c Remove non-trivial constructors/destructors from SystemProperties
With the goal of disallowing exit time destructors, SystemProperties's
non-trivial destructor needs to be removed.  This means replacing the
union hack with yet another hack as we don't want to allocate anything
despite relying on some polymorphism.

Bug: 73485611
Test: boot bullhead
Change-Id: I64223714c9b26c9724bfb8f3e2b0168e47b56bc8
2018-02-21 15:10:17 -08:00
Tom Cherry
e275d6d72d Split properties into their own class to make testing better
Reinitializing system properties can result in crashes later in the
program, and is generally not recommended or even supported.  This
change moves the actual logic for system properties into a class that
can be tested in isolation, without reinitializing the actual system
property area used in libc.

Bug: 62197783
Test: boot devices, ensure properties work
Test: system property unit tests and benchmarks
Change-Id: I9ae6e1b56c62f51a4d3fdb5b62b8926cef545649
2017-12-18 15:17:55 -08:00
Tom Cherry
8a311631ed Allow read-only system properties to have arbitrary lengths
We need to be able to store build fingerprints that are over 92 characters
long, which is the current restriction for system property value
length.

Increasing the value maximum across the board has plenty of caveats,
particularly that an allocator would be required to handle
deallocation when replacing long property values with short values.
There is also no compelling reasons to do this.

But, increasing the length of simply read-only properties, such as the
build fingerprint, has less caveats as there will never be a
deallocation of these strings.

This change uses spare bits in the top of serial (only spare for
read-only properties) to indicate if a property is 'long' or not.  The
information required to access these 'long' properties is stored in a
union where the legacy property value is located.  An error message is
retained for legacy callers.

The new property is readable via __system_property_read_callback() and
most importantly android::base::GetProperty and higher level (Java,
`getprop`) callers.  All code should move to these higher level
functions as much as possible.

Bug: 23102347
Bug: 34954705
Test: bionic unit tests
Change-Id: Ia85e0d979b92afff601cc52b39114379617a0c64
2017-10-10 15:52:25 -07:00
Elliott Hughes
438e01940b Un-deprecated __system_property_find_nth.
Netflix was using this, and looking the header file, although
__system_property_find_nth has been available since the beginning of time,
__system_property_foreach only appeared in 16. So anyone who wants to run
on pre-JellyBean devices would want to use __system_property_find_nth.

It's pretty much a one-liner in terms of __system_property_foreach anyway,
so it doesn't cost us anything to keep it.

Also restore slightly better tests than we originally removed.

Bug: http://b/36566667
Test: ran tests
Change-Id: Id268c2c2e848da17bb0a5a5420af234d9dcb829a
2017-04-17 14:53:07 -07:00
Victor Khimenko
4a92ffd302 Stop using __system_property_area__
Apparently that "backdoor" is no longer needed - the proper way is
to reinitialize properties:
    https://android-review.googlesource.com/#/c/181794/24/tests/system_properties_test.cpp

Also removes mentions of libnativehelper test (it no longer uses
__system_property_area__) and removes useless "extern" declaration
(actual use was removed long ago).

Test: refactoring CL, existsing tests still pass

BUG=21852512
BUG=34114501

Change-Id: I2223cab2fcb671ea180ad4470a7aba5c9cd20bd8
2017-03-01 20:43:42 +01:00
Elliott Hughes
40c885a4d1 Add timeout support to __system_property_wait.
Bug: http://b/35201172
Test: ran tests
Change-Id: I3a78813bf3cd50d1b308ecb3c742f923606c0cc4
2017-02-21 14:36:24 -08:00
Elliott Hughes
a0d374d587 Add __system_property_wait and return the serial in __system_property_read_callback.
In order to implement android::base::WaitForProperty well, we need a way to
wait not for *any* property to change (__system_property_wait_any), but to
specifically wait for the property represented by a given `prop_info` to
change.

The android::base::WaitForProperty implementation, like attempts to cache
system properties in the past, also needs a way to keep serials and values
in sync, but the existing functions don't provide a cheap way to get a
consistent snapshot. Change the __system_property_read_callback callback's
type to include the serial corresponding to the given value.

Add a test, slightly clean up some of the existing tests (and name them to
include the names of the functions they're testing, in our usual style).

Bug: http://b/35201172
Test: ran tests
Change-Id: Ibc8ebe2e88eef1e333a1bd3dd7f68135f1ba7fb5
2017-02-13 13:30:10 -08:00
Dimitry Ivanov
16b2a4de14 Revert "Revert "Remove limit of system property name length""
This reverts commit 489f58b5ea.
Bug: http://b/33926793
Bug: http://b/34670529
Test: Run bionic-unit-tests --gtest_filter=prop*

Change-Id: Id4e94652dc2310a21f5b7bd3af098bf79df3f380
2017-01-24 12:58:18 -08:00
Dimitry Ivanov
489f58b5ea Revert "Remove limit of system property name length"
This reverts commit 5c1ce278f3.
Bug: http://b/33926793
Bug: http://b/34670529

Change-Id: I0dc4a8ae55576c69b34b2958d8e664f7066b9c54
2017-01-24 18:39:04 +00:00
Dimitry Ivanov
5c1ce278f3 Remove limit of system property name length
This change introduces new __system_property_read_callback
method to use in place of deprecated __system_property_read
__system_property_set() and get() should just work but now
do not have limit on system property names.

Bug: http://b/33926793
Test: boot device, run adb shell propget
Test: boot device with old version of init (protocol v1)
Test: run bionic-unit-tests --gtest_filter=prop*
Change-Id: I619fb5a7e27a272aac30011579665f6160888bc7
2017-01-23 11:21:18 -08:00
Dimitry Ivanov
581b9f661b Hide __system_property_add/update, deprecate find_nth
These functions are supposed to be used only by the
property service.

__system_property_find_nth is deprecated and no longer part
of NDK. Call to this function will result in abort for apps
targeting Android O.

Bug: http://b/34114501
Test: bionic-unit-tests --gtest_filter=prop*
Change-Id: I9846965bf248e2ddf45cd7b293618245bbd87145
2017-01-10 13:41:27 -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
Yabin Cui
9df70403d9 make all bionic death tests not dumpable
Bug: 18067305

Change-Id: Ia1ecacf47eddecc9bc58aaac779e0c218f463179
2014-11-06 11:09:03 -08:00
Christopher Ferris
f04935c85e Make sure that the same tests are on all platforms.
In order to be able to generate a list of tests for cts, the same set of
tests must exist across all platforms. This CL adds empty tests where a
test was conditionally compiled out.

This CL creates a single library libBionicTests that includes all of
the tests found in bionic-unit-tests-static.

Also fix a few missing include files in some test files.

Tested by running and compiling the tests for every platform and
verifying the same number of tests are on each platform.

Change-Id: I9989d4bfebb0f9c409a0ce7e87169299eac605a2
2014-02-06 20:12:21 -08:00
The Android Open Source Project
f00c938c7f Merge commit '811b0cdb2d6e4a697dbc63a678712759dd0db242' into HEAD
Change-Id: I786944f80fb1a2d502fed51dc2c391ed5db66761
2013-11-22 13:38:33 -08:00
Elliott Hughes
e4375196d6 Fix the system property tests to use $ANDROID_DATA.
This lets them work on the host.

Change-Id: I771ccc67652ae37451b45859c7831116cd830086
2013-10-21 17:40:15 -07:00
Christopher Ferris
2389a26705 am c058154b: am c8039337: Merge "Change hard-coded temporary directory."
* commit 'c058154b747f295c98ad771d3dec4065749ee1a9':
  Change hard-coded temporary directory.
2013-08-16 12:25:58 -07:00
Christopher Ferris
bd6dc6a886 Change hard-coded temporary directory.
The properties tests creates a temporary directory in /data/nativetest,
but this directory might not exist in all circumstances.
Change this to create the temporary directory in /data/local/tmp.

Change-Id: I812d3e24fcd084c5d74055c9faa95b1656f255bc
2013-08-15 12:54:40 -07:00
Greg Hackmann
be30c7a78a bionic: revert to a single (larger) property area
d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Change-Id: Icd137669a4f8bc248e9dd2c1e8cc54e9193c9a6d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-25 13:34:32 -07:00
Greg Hackmann
d5276422ca bionic: add hierarchical properties test
Deliberately put items several levels deep in the trie hierarchy to test
the trie traversal

Change-Id: I995a1cdd3b5e74162fb5d25bc0f65140bdf2f719
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-25 13:34:29 -07:00
Greg Hackmann
890aa0d937 Revert "bionic: add hierarchical properties test"
This reverts commit 0f76e2340c.
2013-06-24 18:05:18 -07:00
Greg Hackmann
fa8cc0629f Revert "bionic: revert to a single (larger) property area"
This reverts commit 5f05348c18.
2013-06-24 18:05:16 -07:00
Greg Hackmann
1540f601be bionic: revert to a single (larger) property area
d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 5f05348c18)

Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f
2013-06-24 16:35:37 -07:00
Greg Hackmann
cb215a7e9e bionic: make property area expandable
The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

To avoid duplicating code, __system_property_area_init() now allocates
and initializes the first region (previously it was allocated in init's
init_property_area() and initialized in bionic).  For testing purposes,
__system_property_set_filename() may be used to override the file used
to map in regions.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit d32969701b)

Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
2013-06-24 16:35:15 -07:00
Greg Hackmann
5f05348c18 bionic: revert to a single (larger) property area
d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Change-Id: I0ecb27843404f93af5489f15bfe657d65175e4f0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 16:15:52 -07:00
Greg Hackmann
0f76e2340c bionic: add hierarchical properties test
Deliberately put items several levels deep in the trie hierarchy to test
the trie traversal

Change-Id: Id3cbd2e7d3500216b1ac8025eac70c0939622903
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-24 13:14:10 -07:00
Greg Hackmann
d32969701b bionic: make property area expandable
The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

To avoid duplicating code, __system_property_area_init() now allocates
and initializes the first region (previously it was allocated in init's
init_property_area() and initialized in bionic).  For testing purposes,
__system_property_set_filename() may be used to override the file used
to map in regions.

Change-Id: Ibe00ef52464bfa590953c4699a6d98383b0142b1
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-19 11:02:15 -07:00
Greg Hackmann
c6ff844d75 bionic: add __system_property_foreach
find_nth() will be inefficient on a trie.  Since find_nth() is only used
internally and only for enumerating properties, we can add a foreach()
function to do this directly.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 577418403d)

Change-Id: Iaca97d1182ce2c28863ba85241cbb5cf6185eb2f
2013-06-18 19:24:29 -07:00
Greg Hackmann
577418403d bionic: add __system_property_foreach
find_nth() will be inefficient on a trie.  Since find_nth() is only used
internally and only for enumerating properties, we can add a foreach()
function to do this directly.

Change-Id: I66bde9926c193073d74b244cce9fffd52108fff8
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2013-06-18 15:38:31 -07:00
Colin Cross
b27e200ad6 bionic: add tests for properties
(cherry picked from commit 37d9f75dde)

Change-Id: Iac00ce10a4272032a1cbdbc4204277d6876e3365
2013-06-17 16:58:47 -07:00
Colin Cross
37d9f75dde bionic: add tests for properties
Change-Id: I09b212966f1c9624631653ef2c7a71de78bbbec1
2013-06-17 12:58:18 -07:00