external/libdrm
Revision | 9d3b62ffa31538cbb3b8df05d664d5d3aa67403f (tree) |
---|---|
Zeit | 2019-10-04 18:15:43 |
Autor | Mauro Rossi <issor.oruam@gmai...> |
Commiter | Chih-Wei Huang |
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
Reported-by: Mauro Rossi <issor.oruam@gmail.com>
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
@@ -60,16 +60,16 @@ struct gralloc_handle_t { | ||
60 | 60 | uint32_t usage; /* android libhardware usage flags */ |
61 | 61 | |
62 | 62 | uint32_t stride; /* the stride in bytes */ |
63 | - uint64_t modifier; /* buffer modifiers */ | |
64 | - | |
65 | 63 | int data_owner; /* owner of data (for validation) */ |
64 | + uint64_t modifier __attribute__((aligned(8))); /* buffer modifiers */ | |
65 | + | |
66 | 66 | union { |
67 | 67 | void *data; /* pointer to struct gralloc_gbm_bo_t */ |
68 | 68 | uint64_t reserved; |
69 | 69 | } __attribute__((aligned(8))); |
70 | 70 | }; |
71 | 71 | |
72 | -#define GRALLOC_HANDLE_VERSION 3 | |
72 | +#define GRALLOC_HANDLE_VERSION 4 | |
73 | 73 | #define GRALLOC_HANDLE_MAGIC 0x60585350 |
74 | 74 | #define GRALLOC_HANDLE_NUM_FDS 1 |
75 | 75 | #define GRALLOC_HANDLE_NUM_INTS ( \ |