Commit Graph

106 Commits

Author SHA1 Message Date
Ian Pedowitz 6880307e8e Revert "Track ashmem memory usage in Parcel"
This reverts commit e2f499fb73.

Bug: 25169267
Bug: 25191602
Bug: 25004154
Change-Id: I24bb0da4e8739ee5a0c251e4adac9904827144e0
2015-10-22 22:09:16 +00:00
Adrian Roos e2f499fb73 Track ashmem memory usage in Parcel
Bug: 25004154
Change-Id: Id9d5656dd0605f1b50525596b75601309f67ebdc
2015-10-21 22:32:35 +00:00
Chad Brubaker e59cb43eda Fix writeByteArray/writeInt32Array size on x64
writeByteArray writes the size using sizeof(size_t), however it is always
read using readInt32(). On devices where sizeof(size_t) != 4 this causes
extra bytes to be written.

BUG: 22204736
Change-Id: I8d4507b6b616857ef5827f1fe9da0907d09abf0e
2015-06-30 14:50:09 -07:00
Christopher Tate ed7a50cc7d Prevent integer overflow when calculating buffer resizes
Make sure that we don't go haywire if an exponential buffer growth
operation winds up wrapping integer range.  Along the way, fix a
bookkeeping bug in BufferedTextOutput that would cause it to keep
spuriously realloc()ing on every append().

Bug 20674694

Change-Id: Ia845b7de36b90672a151a918ffc26c7da68e20a2
2015-06-08 14:49:09 -07:00
Christopher Tate 98e67d352b Don't corrupt parcel when writeFileDescriptor() fails
We now check for fd-legality before committing binder objects to
the flattened data buffer rather than after.  Previously we would
wind up corrupting the parcel and incurring driver-level errors,
as well as potentially leaking FDs.

Bug 21428802

Change-Id: Ice0d641b3dcc41fb1b8c68ce2e2ebd744c2863a1
2015-06-08 13:13:19 -07:00
Jeff Brown 13b1604018 Enable more flexible usage of blobs in parcels.
Add functions to allow a client to take over the ashmem region
that was transferred so that it can claim it for its own and
reuse it.

Add support for mutable ashmem regions too.

Bug: 21428802
Change-Id: I16eca338cdb99b07d81fc43573d53ce86dbc60c8
2015-06-05 17:40:59 -07:00
Tim Kilbourn 9e6d2ee030 DO NOT MERGE Remove unused ParcelFileDescriptor methods in parcel.
Attempts to replicate Java parceling in native code is fraught with
peril.

Change-Id: I4359036c5dddd1b886d886beef1d060523e53e5f
(cherry picked from commit f47a381001)
2015-06-04 21:36:21 +00:00
Christopher Tate 27182be9f2 Disregard alleged binder entities beyond parcel bounds
When appending one parcel's contents to another, ignore binder
objects within the source Parcel that appear to lie beyond the
formal bounds of that Parcel's data buffer.

Bug 17312693

Change-Id: If592a260f3fcd9a56fc160e7feb2c8b44c73f514
2015-05-27 19:20:15 -07:00
Adam Lesinski eaac99a717 Verify that the native handle was created
The inputs to native_handle_create can cause an overflowed allocation,
so check the return value of native_handle_create before accessing
the memory it returns.

Bug:19334482
Change-Id: I1f489382776c2a1390793a79dc27ea17baa9b2a2
2015-05-12 17:35:48 -07:00
Nick Kralevich e9881a3961 Parcel.cpp: use calloc instead of malloc
(cherrypicked from commit 6329f0199e)

Bug: 20669363
Change-Id: Ia4c8d8ca9d8b4b87954d7267e8b1c94cf4e570e1
2015-04-28 21:31:20 -07:00
Dan Sandler aa5c2346c7 Add ashmem stats to Parcels
Requires change Ifaf115da in frameworks/base.

Bug: 20079551
Change-Id: Ifaf115dabd1a59cdb1b46e2d49c41f64ac107de4
2015-04-16 04:08:53 +00:00
Nick Kralevich b6b1423c87 Parcel.cpp: reject size_t arguments greater than INT32_MAX
It's a security best practice for size_t values to be rejected if
they are greater than INT32_SIZE. This is intended to prevent the
common error of inadvertently passing a negative int value to a
function, which after conversion to an unsigned type, becomes a huge
number, defeating the purpose of bounds checking.

This patch also addresses a bug where the call to:
  Parcel::write(buf, (size_t) -1);
would call writeInPlace() which uses PAD_SIZE on the supplied
argument. This would then cause an integer overflow, with PAD_SIZE
returning a small value, but the memcpy in Parcel::write using the
old large length value.

Bug: 19573085
Change-Id: Ib11bfb3dae4f3be91cd17b2c676926700972c7b8
2015-04-02 10:56:12 -07:00
Ronghua Wu 2d13afdfa1 binder: add uint64 support to Parcel.
Bug: 19620911
Change-Id: Ifce5319e4e35afd344dead67ab7ba1cd399476a3
2015-03-19 16:45:04 -07:00
Jeff Sharkey 499127eab8 am 8f3ade0c: Merge "Follow StrictMode refactoring."
* commit '8f3ade0c9ab52a1e4f13d6ff1922dd98e3ccdbcc':
  Follow StrictMode refactoring.
2015-01-16 06:07:31 +00:00
Jeff Sharkey 0c1f5cbb8a Follow StrictMode refactoring.
Bug: 18335678
Change-Id: Iea920cfa26b5ebfd77b4601c9e6e65b21599342a
2015-01-14 10:58:52 -08:00
Dan Stoza e4ea03f74d am 80e81505: Merge "binder: Add {read,write}Uint32 methods to Parcel"
* commit '80e8150549c9d8380dadf942336d41ab3d92bf78':
  binder: Add {read,write}Uint32 methods to Parcel
2014-12-01 19:27:00 +00:00
Dan Stoza 41a0f2f86c binder: Add {read,write}Uint32 methods to Parcel
Adds readUint32 and writeUint32 methods to the Parcel class. This
saves a lot of static_casting in anything implementing a Binder
interface on the native side.

Change-Id: Iafc73b0633654a3a4c49767f41806b56906c924f
2014-12-01 11:13:11 -08:00
Dan Albert c1ced8bbcd am c894c204: Merge "C++11 compatibility."
* commit 'c894c2045f589571c80af0648e7a9dcd7e97b6a8':
  C++11 compatibility.
2014-11-20 23:00:48 +00:00
Dan Albert 3bdc5b8268 C++11 compatibility.
* Explicit conversion for atomic_uintptr_t initialization.
 * Fix string literal concatenation to not be a UD literal.
 * Use __typeof__ instead of typeof (should become decltype once this
   actually moves to C++11).

Bug: 18466763
Change-Id: I4eedddfb945a2a703ed27317cb6e2b3041b1ebfc
2014-11-20 21:04:35 +00:00
Dianne Hackborn a4cff88d80 Fix issue #18356768: some app process may hang at Runtime#exit...
...in Parcel destructor

Don't use a Mutux object, just use simple posix mutex primitives,
to avoid static init/destroy order problems.

Change-Id: Ic012d94297564c0a55d58869f8276d7d10545fbc
2014-11-13 17:09:59 -08:00
Dianne Hackborn 7e790af756 Add tracking of parcel memory allocations.
Change-Id: I76ffed0e69ccfe70e87d98646f11d4de7c3fd980
2014-11-11 16:23:04 -08:00
Jesse Hall fee99040de Revert "Add more logging for dup(fd) failure"
Underlying bug has been fixed, extra debug code no longer needed

This reverts commit 36273c991b.

Change-Id: Ia47f1ae9ee7338329bfb8d710aff57e15e944f20
2014-11-04 08:48:16 -08:00
Jesse Hall 8e5cf83afb Revert "Parcel: extra validation/debug code for writeDupFileDescriptor"
Underlying bug has been fixed, extra debug code no longer needed.

This reverts commit ccf851f108.

Change-Id: I19ad9239efdf1d8f70cd74af9b7c2ae97713208f
2014-11-04 08:47:57 -08:00
Narayan Kamath 9ea09757fa Fix broken error check in Parcel::readBlob
mmap returns MAP_FAILED (which is -1) and not NULL on
failure.

Diagnosed by cferris.

bug: 17909809

Change-Id: I609788ebf94742ef88af002d2d3f3bc9b9e520ac
2014-10-08 17:37:38 +01:00
Jesse Hall ccf851f108 Parcel: extra validation/debug code for writeDupFileDescriptor
Temporary extra debug validation for b/17477219: a Parcel recipient is
getting a positive but invalid fd unexpectedly. Trying to track down
where it's coming from.

Debug code for bug: 17477219
Change-Id: Idb1e71621025a3928c7adc88fd44790e1abd2a01
2014-10-06 15:23:56 -07:00
Michael Lentine 36273c991b Add more logging for dup(fd) failure
Bug: 17477219
Change-Id: Ide0ae16d777c9af783023c705c18a93c00999147
2014-10-02 18:13:02 +00:00
Narayan Kamath 7da40c0a84 Remove Parcel::writeIntPtr.
All uses of this API have been removed. It should
never have been made public in the first place.

bug: 15424960
Change-Id: Id07d24ec95b2b393e6da138a7e8a9a4ecebeca94
2014-06-12 15:26:39 +01:00
Narayan Kamath 87947be618 Merge "Fix mips build for libbinder." 2014-06-04 14:32:59 +00:00
Narayan Kamath 2c68d380c9 Fix mips build for libbinder.
Mips specific code was using an uninitialized variable.

Change-Id: I445043c76ebfa420b26376ade60f8068b4ea0b11
2014-06-04 15:05:13 +01:00
Mark Salyzyn b09b936d8e am f0a24759: am a28750ee: Merge "binder: Turn on -Werror"
* commit 'f0a2475905786d5457e7af838ac714acbfdafa4f':
  binder: Turn on -Werror
2014-06-03 20:54:48 +00:00
Mark Salyzyn f0a2475905 am a28750ee: Merge "binder: Turn on -Werror"
* commit 'a28750eec38c848230adfeef28725b29cc36a9da':
  binder: Turn on -Werror
2014-06-03 20:48:35 +00:00
Mark Salyzyn d4ecccfd20 binder: Turn on -Werror
Change-Id: I0ee785927a7ae5f731b02176b0b781b87c22a24e
2014-06-03 11:11:45 -07:00
Jesse Hall 13de7f1def am 57fdbbda: am 4314ccd1: am 70278fbf: Merge "Add error message for hints when exceptions occur during binder transactions."
* commit '57fdbbda2c475d2abdd828177f942ddb6d164bef':
  Add error message for hints when exceptions occur during binder transactions.
2014-05-05 17:33:01 +00:00
Jesse Hall 57fdbbda2c am 4314ccd1: am 70278fbf: Merge "Add error message for hints when exceptions occur during binder transactions."
* commit '4314ccd1ba9fe773b0fc91f0a08dc536ebce8dfe':
  Add error message for hints when exceptions occur during binder transactions.
2014-05-05 17:30:19 +00:00
Jesse Hall 4314ccd1ba am 70278fbf: Merge "Add error message for hints when exceptions occur during binder transactions."
* commit '70278fbfe012c1fce3e63a41ffb9feaf1e53a64a':
  Add error message for hints when exceptions occur during binder transactions.
2014-05-05 17:27:46 +00:00
Jun Jiang abf8a2c608 Add error message for hints when exceptions occur during binder transactions.
It can help to detect some kind of error, such as why GraphicBuffer::flatten
will crash when handle is null.

Change-Id: I703cd035b96edb7afb324cf24d8230d4e55f4f52
Signed-off-by: Jun Jiang <jun.a.jiang@intel.com>
2014-04-29 14:22:10 +08:00
Kenny Root 75d8406934 am ca609e43: am 38e2aaaa: am 5b61ad2c: Check the padded size of the read byte array
* commit 'ca609e4300d88ad1e815581ebc6a478b446d3882':
  Check the padded size of the read byte array
2014-03-17 23:32:59 +00:00
Kenny Root ca609e4300 am 38e2aaaa: am 5b61ad2c: Check the padded size of the read byte array
* commit '38e2aaaa3dd62a20eb211808ae6fe45ec37ee6d5':
  Check the padded size of the read byte array
2014-03-17 21:31:04 +00:00
Kenny Root 9ff2aad010 am 5b61ad2c: Check the padded size of the read byte array
* commit '5b61ad2cda8ec8ab634ce02f388bb2d3c5ab048d':
  Check the padded size of the read byte array
2014-03-17 21:28:33 +00:00
Kenny Root 5b61ad2cda Check the padded size of the read byte array
Bug: 13509200
Change-Id: Id93894fcc617ec1cd4ce66921c6e1f1c3cf40b09
2014-03-17 13:18:16 -07:00
Marco Nelissen ce9f107c9d am 793be12c: am b730a452: am f0190bff: Add support for writing byte arrays to parcels
* commit '793be12c0f5a7878d1085e94e58a9c36c84f0911':
  Add support for writing byte arrays to parcels
2014-03-15 00:30:46 +00:00
Marco Nelissen 793be12c0f am b730a452: am f0190bff: Add support for writing byte arrays to parcels
* commit 'b730a45216991cf22c39451c47393b4bccae111b':
  Add support for writing byte arrays to parcels
2014-03-14 23:33:08 +00:00
Marco Nelissen 446ef4bae2 am f0190bff: Add support for writing byte arrays to parcels
* commit 'f0190bff38b6c29abbfc4a877442f71fc3d7dad8':
  Add support for writing byte arrays to parcels
2014-03-14 23:32:45 +00:00
Marco Nelissen f0190bff38 Add support for writing byte arrays to parcels
b/13418320

Change-Id: I2285df9e9d3dc8a6a54055b13b352b81660bf45d
2014-03-13 14:17:40 -07:00
Arve Hjønnevåg 614019cd1f am d1c87d37: Merge changes I3432d9d3,I90fcf538,I64398603
* commit 'd1c87d37025c49f6a47fe43328572da495ff04c1':
  Binder: Fix some valgrind errors.
  Binder: Don't cast directly from a pointer to binder_uintptr_t
  Binder: Disable attemptIncStrongHandle
2014-03-10 18:06:10 +00:00
Colin Cross 8ff043d3fb am 74be0f7b: Merge "binder: fix all warnings"
* commit '74be0f7be35e7b40a322fa9a407cb49265333a0b':
  binder: fix all warnings
2014-03-07 02:23:38 +00:00
Arve Hjønnevåg eea5b29842 am 58242fc2: Merge changes Ib0e5a037,I1bd7c38e,Icfc67c2a,I96c64312,I59528054, ...
* commit '58242fc29881cf29d56ee6e5fde6d73b16d0b67c':
  ServiceManager: Implement PING_TRANSACTION
  ServiceManager: Use 32/64 bit types from new binder header
  Binder: Use 64 bit pointers in 32 processes if selected by the target
  Add BINDER_IPC_32BIT to CFLAGS unless TARGET_USES_64_BIT_BINDER is true
  Binder: Make binder portable
  ServiceManager: Fix the binder interface
  ServiceManager: Store handles in uint32_t instead of void *
  ServiceManager: Generic Fixes
  ServiceManager: Add extra error handling
  ServiceManager: Fix Android.mk
  ServiceManager: Make use of kernel exported structures
2014-03-07 01:34:26 +00:00
Arve Hjønnevåg 4cab0fd7f7 Binder: Make sure binder objects do not overlap
Fixes crashing part of bug 11355082.
The driver still leaks references.

Change-Id: Ibc6a63b151c1fc1f7666237f25255ba781e02071
2014-02-24 15:42:13 -08:00
Arve Hjønnevåg 3c98ba77b9 am c5294424: am d1c87d37: Merge changes I3432d9d3,I90fcf538,I64398603
* commit 'c5294424386bedad2a240074d0845999f28e662d':
  Binder: Fix some valgrind errors.
  Binder: Don't cast directly from a pointer to binder_uintptr_t
  Binder: Disable attemptIncStrongHandle
2014-02-22 00:52:18 +00:00
Arve Hjønnevåg c529442438 am d1c87d37: Merge changes I3432d9d3,I90fcf538,I64398603
* commit 'd1c87d37025c49f6a47fe43328572da495ff04c1':
  Binder: Fix some valgrind errors.
  Binder: Don't cast directly from a pointer to binder_uintptr_t
  Binder: Disable attemptIncStrongHandle
2014-02-22 00:41:31 +00:00