OSDN Git Service

Fix 32-bit app crashing in 64-bit Android (v2)
authorMauro Rossi <issor.oruam@gmail.com>
Tue, 11 Dec 2018 22:22:35 +0000 (23:22 +0100)
committerMauro Rossi <issor.oruam@gmail.com>
Thu, 13 Dec 2018 22:31:19 +0000 (23:31 +0100)
commit2b1c1f2e980fbec59d3adae3eea6c09a9da673eb
treeb456710e7c4286149d9fa3da92914e1c43bad352
parent072278873bc4c90f6e1e3f96d81269aa0dcf5ecb
Fix 32-bit app crashing in 64-bit Android (v2)

Seemingly the 64-bit int is always aligned to 8 in LP64.
But this is not hold in LP32.

Consequently sizeof(gralloc_drm_handle_t) are different
between LP64 (which is 18 ints) and LP32 (which is 16 ints).
As a result, 32-bit apps will crash in 64-bit OS since the
checking handle->base.numInts != GRALLOC_GBM_HANDLE_NUM_INTS
is true.

Fix it by always aligning 64-bit int to 8. Besides, to avoid
additional padding, just exchange the order of data_owner
and modifier. It aligns modifier to 8 natually.
This makes gralloc_drm_handle_t fit in 16 ints perfectly.

(v2) gralloc_drm_handle.h patch now applied in gralloc_handle.h
     and GRALLOC_HANDLE_VERSION updated to 4

Reported-by: Mauro Rossi <issor.oruam@gmail.com>
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
android/gralloc_handle.h