Commit Graph

35584 Commits

Author SHA1 Message Date
Ting-Yuan Huang 78a298ce24 Merge "Fix a potential memory leak" am: f583ff660e am: 6677429bff
am: 6deffe3c3b

Change-Id: Ifcd960527a5da12e136ba96062460208368aafea
2017-08-16 17:34:11 +00:00
Ting-Yuan Huang 6deffe3c3b Merge "Fix a potential memory leak" am: f583ff660e
am: 6677429bff

Change-Id: I47d668eb5f56dd51f99415e50ff7f3ab901a18e1
2017-08-16 17:18:44 +00:00
Ting-Yuan Huang 6677429bff Merge "Fix a potential memory leak"
am: f583ff660e

Change-Id: Ib6c7f4b328d91c59248a20486f49fb1f3d8051a0
2017-08-16 17:06:44 +00:00
Treehugger Robot f583ff660e Merge "Fix a potential memory leak" 2017-08-16 16:55:54 +00:00
Jocelyn Bohr eb7207dbcd Merge "Pass in message_version_ received from the secure side." am: 1a955faab2 am: 4e8bbb968c
am: 3a5d47af18

Change-Id: If57d80e166bb9ffd915ffe58ebb371bb3ada91c1
2017-08-16 00:13:37 +00:00
Jocelyn Bohr 3a5d47af18 Merge "Pass in message_version_ received from the secure side." am: 1a955faab2
am: 4e8bbb968c

Change-Id: I0d462bab958d2b3378debbff397ba11933fc681c
2017-08-16 00:04:05 +00:00
Jocelyn Bohr 4e8bbb968c Merge "Pass in message_version_ received from the secure side."
am: 1a955faab2

Change-Id: I39906a476272c781b37c20707bea0fbe1244305e
2017-08-15 23:53:32 +00:00
Ting-Yuan Huang f26cf6d520 Fix a potential memory leak
Test: Built without seeing the warnings
Change-Id: I934509c78482af9ef7dc447c807f6450484b4b38
2017-08-15 16:48:24 -07:00
Treehugger Robot 1a955faab2 Merge "Pass in message_version_ received from the secure side." 2017-08-15 23:35:48 +00:00
Christopher Ferris 784d6626fb Merge "Decrease size of LogBufferElements to 32 bytes." am: 44ad937411 am: e23b30a6da
am: 90c25cbdd3

Change-Id: Iaadb84c017b37edfaf54505c9aa845f1d9e4e67b
2017-08-15 17:09:59 +00:00
Christopher Ferris 90c25cbdd3 Merge "Decrease size of LogBufferElements to 32 bytes." am: 44ad937411
am: e23b30a6da

Change-Id: I0599743340e11e08ca509f1ca6de1eb50ebd8802
2017-08-15 17:05:03 +00:00
Christopher Ferris e23b30a6da Merge "Decrease size of LogBufferElements to 32 bytes."
am: 44ad937411

Change-Id: Ibfcc70ed00e8d76a3ff77e0e00cdf922bc65b55f
2017-08-15 17:00:02 +00:00
Christopher Ferris 44ad937411 Merge "Decrease size of LogBufferElements to 32 bytes." 2017-08-15 16:53:56 +00:00
Tom Cherry 7d98d28a7b Merge changes I7f00c5f0,Idc18f331,I1e7d3a88 am: 334929b525 am: db640d87cd -s ours
am: fd0ec51c3b  -s ours

Change-Id: If727ebf2eabe3aba26a1005797e4945db5411243
2017-08-14 23:02:23 +00:00
Tom Cherry fd0ec51c3b Merge changes I7f00c5f0,Idc18f331,I1e7d3a88 am: 334929b525
am: db640d87cd  -s ours

Change-Id: I5961da04d21899410516a3c3d7228d29f2c2b0bb
2017-08-14 22:57:58 +00:00
Tom Cherry db640d87cd Merge changes I7f00c5f0,Idc18f331,I1e7d3a88
am: 334929b525

Change-Id: If6526adf256c1e5958d5aa6135d9e7efd11cf1cf
2017-08-14 22:52:34 +00:00
Tom Cherry 334929b525 Merge changes I7f00c5f0,Idc18f331,I1e7d3a88
* changes:
  init: use Result<T> for the parsing functions
  init: use Result<T> for builtin functions
  init: introduce Result<T> for return values and error handling
2017-08-14 22:43:23 +00:00
Tom Cherry 082798acba Merge changes I7f00c5f0,Idc18f331,I1e7d3a88 into oc-dev-plus-aosp
am: 8f3f53f504  -s ours

Change-Id: I88ec73ba4613dcb4a309b68f9635f07c652e3807
2017-08-14 21:10:45 +00:00
Tom Cherry 89bcc85edf init: use Result<T> for the parsing functions
Test: boot bullhead
Merged-In: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-08-14 14:07:49 -07:00
Tom Cherry 557946e57c init: use Result<T> for builtin functions
We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context.  This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead
Merged-In: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
2017-08-14 14:07:39 -07:00
Tom Cherry 11a3aeeae3 init: introduce Result<T> for return values and error handling
init tries to propagate error information up to build context before
logging errors.  This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &output, &calculate_result_err)) {
    *err = "CalculateResult " + input + " failed: " +
      calculate_result_err;
      return false;
  }
  UseResult(output);
  return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string.  If the functional only returns success or a failure with
an error message, Result<Success> may be used.  The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T.  This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure.  ErrnoError()
additionally appends ": " + strerror(errno) to the end of  the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() << "CalculateResult " << input << " failed: "
                   << output.error();
  }
  UseResult(*output);
  return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Merged-In: I1e7d3a8820a79362245041251057fbeed2f7979b
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
2017-08-14 14:07:30 -07:00
Tom Cherry 8f3f53f504 Merge changes I7f00c5f0,Idc18f331,I1e7d3a88 into oc-dev-plus-aosp
* changes:
  init: use Result<T> for the parsing functions
  init: use Result<T> for builtin functions
  init: introduce Result<T> for return values and error handling
2017-08-14 20:50:27 +00:00
Tom Cherry 08adddec07 Merge changes I7f00c5f0,Idc18f331,I1e7d3a88 into oc-dr1-dev-plus-aosp
* changes:
  init: use Result<T> for the parsing functions
  init: use Result<T> for builtin functions
  init: introduce Result<T> for return values and error handling
2017-08-14 20:20:50 +00:00
Tom Cherry 7c06854a62 Merge "init: split security functions out of init.cpp" into stage-aosp-master am: 9e16932c04 -s ours
am: da8e47903c  -s ours

Change-Id: I390d3b261dd97ab8935ae71ccd26b7d5b4f9aed6
2017-08-14 18:57:39 +00:00
Tom Cherry da8e47903c Merge "init: split security functions out of init.cpp" into stage-aosp-master
am: 9e16932c04  -s ours

Change-Id: I7b44df3d8746f50781a707169f11fb6fddbb756a
2017-08-14 18:53:35 +00:00
TreeHugger Robot 9e16932c04 Merge "init: split security functions out of init.cpp" into stage-aosp-master 2017-08-14 18:47:58 +00:00
Tom Cherry 3b3d1ab7e5 Merge "init: split security functions out of init.cpp" am: d467db9b3d -s ours am: 6beea94675 -s ours
am: 31df396206  -s ours

Change-Id: I312eb890dc10c2eb7ce647bbbc1ccc1e280b1ab0
2017-08-14 18:22:41 +00:00
Tom Cherry 31df396206 Merge "init: split security functions out of init.cpp" am: d467db9b3d -s ours
am: 6beea94675  -s ours

Change-Id: I0326dde262a9afaeae5a76140fafea88f00fdfbf
2017-08-14 18:18:47 +00:00
Tom Cherry 6beea94675 Merge "init: split security functions out of init.cpp"
am: d467db9b3d  -s ours

Change-Id: I79efe02c3544224c13a6b5f037a8243add2c0eca
2017-08-14 18:13:35 +00:00
Tom Cherry c317009410 init: split security functions out of init.cpp
This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp.  It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop.  The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users.  The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
(cherry picked from commit 9afb86b25d8675927cb37c86119a7ecf19f74819)
2017-08-14 11:07:27 -07:00
Josh Gao 17a034ed4f debuggerd_handler: print pid and process name.
am: 30b69aab46

Change-Id: I8aaf7a90d8c3ab20a5def052198f43777fc44db8
2017-08-14 18:06:26 +00:00
Tom Cherry d467db9b3d Merge "init: split security functions out of init.cpp" 2017-08-14 17:54:38 +00:00
Tom Cherry b592dd8aff init: use Result<T> for the parsing functions
Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-08-14 10:27:33 -07:00
Tom Cherry 7fa62c58d6 init: use Result<T> for builtin functions
We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context.  This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead

Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
2017-08-14 10:27:23 -07:00
Tom Cherry 62ca663475 init: introduce Result<T> for return values and error handling
init tries to propagate error information up to build context before
logging errors.  This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &output, &calculate_result_err)) {
    *err = "CalculateResult " + input + " failed: " +
      calculate_result_err;
      return false;
  }
  UseResult(output);
  return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string.  If the functional only returns success or a failure with
an error message, Result<Success> may be used.  The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T.  This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure.  ErrnoError()
additionally appends ": " + strerror(errno) to the end of  the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() << "CalculateResult " << input << " failed: "
                   << output.error();
  }
  UseResult(*output);
  return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
2017-08-14 10:26:57 -07:00
Tom Cherry 2958df83a7 init: use Result<T> for the parsing functions
Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
2017-08-14 10:25:35 -07:00
Tom Cherry 568947d7d1 init: use Result<T> for builtin functions
We currently throw out the return values from builtin functions and
occasionally log errors with no supporting context.  This change uses
the newly introduced Result<T> class to communicate a successful result
or an error back to callers in order to print an error with clear
context when a builtin fails.

Example:

init: Command 'write /sys/class/leds/vibrator/trigger transient' action=init (/init.rc:245) took 0ms and failed: Unable to write to file '/sys/class/leds/vibrator/trigger': open() failed: No such file or directory

Test: boot bullhead

Change-Id: Idc18f331d2d646629c6093c1e0f2996cf9b42aec
2017-08-14 10:25:26 -07:00
Tom Cherry de09d52328 init: introduce Result<T> for return values and error handling
init tries to propagate error information up to build context before
logging errors.  This is a good thing, however too often init has the
overly verbose paradigm for error handling, below:

bool CalculateResult(const T& input, U* output, std::string* err)

bool CalculateAndUseResult(const T& input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &output, &calculate_result_err)) {
    *err = "CalculateResult " + input + " failed: " +
      calculate_result_err;
      return false;
  }
  UseResult(output);
  return true;
}

Even more common are functions that return only true/false but also
require passing a std::string* err in order to see the error message.

This change introduces a Result<T> that is use to either hold a
successful return value of type T or to hold an error message as a
std::string.  If the functional only returns success or a failure with
an error message, Result<Success> may be used.  The classes Error and
ErrnoError are used to indicate a failed Result<T>.

A successful Result<T> is constructed implicitly from any type that
can be implicitly converted to T or from the constructor arguments for
T.  This allows you to return a type T directly from a function that
returns Result<T>.

Error and ErrnoError are used to construct a Result<T> has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result<T> containing that failure.  ErrnoError()
additionally appends ": " + strerror(errno) to the end of  the failure
string to aid in interacting with C APIs.

The end result is that the above code snippet is turned into the much
clearer example below:

Result<U> CalculateResult(const T& input);

Result<Success> CalculateAndUseResult(const T& input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() << "CalculateResult " << input << " failed: "
                   << output.error();
  }
  UseResult(*output);
  return Success();
}

This change also makes this conversion for some of the util.cpp
functions that used the old paradigm.

Test: boot bullhead, init unit tests
Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
2017-08-14 10:25:14 -07:00
Tom Cherry b6b9629f02 Merge "init: split security functions out of init.cpp" into oc-dev-plus-aosp
am: 08228116a8

Change-Id: I3fc6288cf03cd1e262852ceb3fc9dbcedb32c7c3
2017-08-14 16:50:01 +00:00
Tom Cherry 08228116a8 Merge "init: split security functions out of init.cpp" into oc-dev-plus-aosp 2017-08-14 16:45:19 +00:00
Tom Cherry 0c8d6d2730 init: split security functions out of init.cpp
This change splits out the selinux initialization and supporting
functionality into selinux.cpp and splits the security related
initialization of the rng, etc to security.cpp.  It also provides
additional documentation for SEPolicy loading as this has been
requested by some teams.

It additionally cleans up sehandle and sehandle_prop.  The former is
static within selinux.cpp and new wrapper functions are created around
selabel_lookup*() to better serve the users.  The latter is moved to
property_service.cpp as it is isolated to that file for its usage.

Test: boot bullhead
Merged-In: Idc95d493cebc681fbe686b5160502f36af149f60
Change-Id: Idc95d493cebc681fbe686b5160502f36af149f60
2017-08-14 09:40:01 -07:00
Christopher Ferris a457c32fa9 Merge "Compare new unwinder to old unwinder in debuggerd." am: bb2f03f344 am: 1f6a481462
am: 0a616421d8

Change-Id: I29978d44adb2e04834a0f5011a7bc8e5076588df
2017-08-12 16:17:50 +00:00
Christopher Ferris aa2cab500c Merge "Add demangling of function name." am: 6452b9036d am: e10835f28a
am: 174f78e4cc

Change-Id: Ia0eb87f68222f6dbcb9324e693996345ca89cb8b
2017-08-12 16:17:19 +00:00
Christopher Ferris 0a616421d8 Merge "Compare new unwinder to old unwinder in debuggerd." am: bb2f03f344
am: 1f6a481462

Change-Id: I741f675f1ba3e853614b0310965bf41a6972a22a
2017-08-12 16:14:57 +00:00
Christopher Ferris 174f78e4cc Merge "Add demangling of function name." am: 6452b9036d
am: e10835f28a

Change-Id: Iddb8a90281570eeca52e54a63ef36eede550e3fc
2017-08-12 16:14:17 +00:00
Christopher Ferris 1f6a481462 Merge "Compare new unwinder to old unwinder in debuggerd."
am: bb2f03f344

Change-Id: I3e51fadda629f7d4bda8e4ddc4c0b60ebbdb49b8
2017-08-12 16:11:47 +00:00
Christopher Ferris e10835f28a Merge "Add demangling of function name."
am: 6452b9036d

Change-Id: I7a2b883afb4fca2e8ce754b3bcea867ed0779c5b
2017-08-12 16:11:18 +00:00
Christopher Ferris bb2f03f344 Merge "Compare new unwinder to old unwinder in debuggerd." 2017-08-12 16:06:48 +00:00
Christopher Ferris 6452b9036d Merge "Add demangling of function name." 2017-08-12 16:06:18 +00:00
Josh Gao 30b69aab46 debuggerd_handler: print pid and process name.
Bug: http://b/64483618
Test: manual

(cherry picked from commit 81e6c0b613)

Change-Id: Icd957ccd21c2ce072f4cdf973b94de08fb0c5567
2017-08-11 22:01:36 -07:00