Do not set properties in bionic_systrace
Currently, if the debug.atrace.tags.enableflags property is not found, it is set to a safe value such that a pointer to this property can be stored for later access. This may result in selinux denials because not all processes write permissions for this property or permission to connect to the property write socket at all. Change I6d953c0c281fd72ad3eba8a479fd258023579b5b writes this property to a safe value upon boot, which greatly decreases the cases in which this property will not be accessible and removes the need to write it here. This commit removes this write. Bug 26115803 Change-Id: Ief72c5f731d3a1231b5080eb531fa0a491a8b1d1
This commit is contained in:
parent
e371ae68ac
commit
46e2eadad2
@ -34,27 +34,25 @@ constexpr char SYSTRACE_PROPERTY_NAME[] = "debug.atrace.tags.enableflags";
|
|||||||
|
|
||||||
static Lock g_lock;
|
static Lock g_lock;
|
||||||
static const prop_info* g_pinfo;
|
static const prop_info* g_pinfo;
|
||||||
static uint32_t g_serial = -1;
|
static uint32_t g_property_serial = -1;
|
||||||
|
static uint32_t g_property_area_serial = -1;
|
||||||
static uint64_t g_tags;
|
static uint64_t g_tags;
|
||||||
static int g_trace_marker_fd = -1;
|
static int g_trace_marker_fd = -1;
|
||||||
|
|
||||||
static bool should_trace() {
|
static bool should_trace() {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
g_lock.lock();
|
g_lock.lock();
|
||||||
// If g_pinfo is null, this means that systrace hasn't been run and it's safe to
|
// debug.atrace.tags.enableflags is set to a safe non-tracing value during property
|
||||||
// assume that no trace writing will need to take place. However, to avoid running
|
// space initialization, so it should only be null in two cases, if there are
|
||||||
// this costly find check each time, we set it to a non-tracing value so that next
|
// insufficient permissions for this process to access the property, in which
|
||||||
// time, it will just check the serial to see if the value has been changed.
|
// case an audit will be logged, and during boot before the property server has
|
||||||
// this function also deals with the bootup case, during which the call to property
|
// been started, in which case we store the global property_area serial to prevent
|
||||||
// set will fail if the property server hasn't yet started.
|
// the costly find operation until we see a changed property_area.
|
||||||
if (g_pinfo == NULL) {
|
if (!g_pinfo && g_property_area_serial != __system_property_area_serial()) {
|
||||||
|
g_property_area_serial = __system_property_area_serial();
|
||||||
g_pinfo = __system_property_find(SYSTRACE_PROPERTY_NAME);
|
g_pinfo = __system_property_find(SYSTRACE_PROPERTY_NAME);
|
||||||
if (g_pinfo == NULL) {
|
|
||||||
__system_property_set(SYSTRACE_PROPERTY_NAME, "0");
|
|
||||||
g_pinfo = __system_property_find(SYSTRACE_PROPERTY_NAME);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (g_pinfo != NULL) {
|
if (g_pinfo) {
|
||||||
// Find out which tags have been enabled on the command line and set
|
// Find out which tags have been enabled on the command line and set
|
||||||
// the value of tags accordingly. If the value of the property changes,
|
// the value of tags accordingly. If the value of the property changes,
|
||||||
// the serial will also change, so the costly system_property_read function
|
// the serial will also change, so the costly system_property_read function
|
||||||
@ -62,11 +60,11 @@ static bool should_trace() {
|
|||||||
// first. The values within pinfo may change, but its location is guaranteed
|
// first. The values within pinfo may change, but its location is guaranteed
|
||||||
// not to move.
|
// not to move.
|
||||||
uint32_t cur_serial = __system_property_serial(g_pinfo);
|
uint32_t cur_serial = __system_property_serial(g_pinfo);
|
||||||
if (cur_serial != g_serial) {
|
if (cur_serial != g_property_serial) {
|
||||||
g_serial = cur_serial;
|
g_property_serial = cur_serial;
|
||||||
char value[PROP_VALUE_MAX];
|
char value[PROP_VALUE_MAX];
|
||||||
__system_property_read(g_pinfo, 0, value);
|
__system_property_read(g_pinfo, 0, value);
|
||||||
g_tags = strtoull(value, NULL, 0);
|
g_tags = strtoull(value, nullptr, 0);
|
||||||
}
|
}
|
||||||
result = ((g_tags & ATRACE_TAG_BIONIC) != 0);
|
result = ((g_tags & ATRACE_TAG_BIONIC) != 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user