diff options
author | Arve Hjønnevåg <arve@android.com> | 2016-02-10 00:05:32 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-11 23:06:46 -0500 |
commit | 212265e5ad726ed7fd2ec7d61d36d9e0b0d3e655 (patch) | |
tree | bd7f5e7eb7b39c304e9e907e0240c7d65ea694e0 /drivers/android | |
parent | 46d83a8782e73468c9f744d859fbb6af4d53c520 (diff) |
android: binder: More offset validation
Make sure offsets don't point to overlapping flat_binder_object
structs.
Cc: Colin Cross <ccross@android.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Dmitry Shmidt <dimitrysh@google.com>
Cc: Rom Lemarchand <romlem@google.com>
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android')
-rw-r--r-- | drivers/android/binder.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index a39e85f9efa9..1db376184955 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c | |||
@@ -1321,6 +1321,7 @@ static void binder_transaction(struct binder_proc *proc, | |||
1321 | struct binder_transaction *t; | 1321 | struct binder_transaction *t; |
1322 | struct binder_work *tcomplete; | 1322 | struct binder_work *tcomplete; |
1323 | binder_size_t *offp, *off_end; | 1323 | binder_size_t *offp, *off_end; |
1324 | binder_size_t off_min; | ||
1324 | struct binder_proc *target_proc; | 1325 | struct binder_proc *target_proc; |
1325 | struct binder_thread *target_thread = NULL; | 1326 | struct binder_thread *target_thread = NULL; |
1326 | struct binder_node *target_node = NULL; | 1327 | struct binder_node *target_node = NULL; |
@@ -1522,18 +1523,24 @@ static void binder_transaction(struct binder_proc *proc, | |||
1522 | goto err_bad_offset; | 1523 | goto err_bad_offset; |
1523 | } | 1524 | } |
1524 | off_end = (void *)offp + tr->offsets_size; | 1525 | off_end = (void *)offp + tr->offsets_size; |
1526 | off_min = 0; | ||
1525 | for (; offp < off_end; offp++) { | 1527 | for (; offp < off_end; offp++) { |
1526 | struct flat_binder_object *fp; | 1528 | struct flat_binder_object *fp; |
1527 | 1529 | ||
1528 | if (*offp > t->buffer->data_size - sizeof(*fp) || | 1530 | if (*offp > t->buffer->data_size - sizeof(*fp) || |
1531 | *offp < off_min || | ||
1529 | t->buffer->data_size < sizeof(*fp) || | 1532 | t->buffer->data_size < sizeof(*fp) || |
1530 | !IS_ALIGNED(*offp, sizeof(u32))) { | 1533 | !IS_ALIGNED(*offp, sizeof(u32))) { |
1531 | binder_user_error("%d:%d got transaction with invalid offset, %lld\n", | 1534 | binder_user_error("%d:%d got transaction with invalid offset, %lld (min %lld, max %lld)\n", |
1532 | proc->pid, thread->pid, (u64)*offp); | 1535 | proc->pid, thread->pid, (u64)*offp, |
1536 | (u64)off_min, | ||
1537 | (u64)(t->buffer->data_size - | ||
1538 | sizeof(*fp))); | ||
1533 | return_error = BR_FAILED_REPLY; | 1539 | return_error = BR_FAILED_REPLY; |
1534 | goto err_bad_offset; | 1540 | goto err_bad_offset; |
1535 | } | 1541 | } |
1536 | fp = (struct flat_binder_object *)(t->buffer->data + *offp); | 1542 | fp = (struct flat_binder_object *)(t->buffer->data + *offp); |
1543 | off_min = *offp + sizeof(struct flat_binder_object); | ||
1537 | switch (fp->type) { | 1544 | switch (fp->type) { |
1538 | case BINDER_TYPE_BINDER: | 1545 | case BINDER_TYPE_BINDER: |
1539 | case BINDER_TYPE_WEAK_BINDER: { | 1546 | case BINDER_TYPE_WEAK_BINDER: { |