diff options
author | Arve Hjønnevåg <arve@android.com> | 2016-02-09 21:05:32 -0800 |
---|---|---|
committer | Mattias Nissler <mnissler@google.com> | 2016-07-20 16:18:20 +0200 |
commit | 388508a089416ad72b5ac9b7d98d4942844a728f (patch) | |
tree | 075c4412a707f646de1fa0527c69a61ccd6e8f39 | |
parent | 2b69cc3036042c8abcdceb6f3b6d3c488b6991ad (diff) | |
download | v4.4-388508a089416ad72b5ac9b7d98d4942844a728f.tar.gz |
UPSTREAM: 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>
Bug: None
Patchset: binder
(cherry-picked from 212265e5ad726ed7fd2ec7d61d36d9e0b0d3e655)
Signed-off-by: Mattias Nissler <mnissler@google.com>
Change-Id: Id031d8f05486402cdce64f5cd360085746704a18
-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 7d00b7a015ea..25609dd7c2d0 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -1321,6 +1321,7 @@ static void binder_transaction(struct binder_proc *proc, struct binder_transaction *t; struct binder_work *tcomplete; binder_size_t *offp, *off_end; + binder_size_t off_min; struct binder_proc *target_proc; struct binder_thread *target_thread = NULL; struct binder_node *target_node = NULL; @@ -1522,18 +1523,24 @@ static void binder_transaction(struct binder_proc *proc, goto err_bad_offset; } off_end = (void *)offp + tr->offsets_size; + off_min = 0; for (; offp < off_end; offp++) { struct flat_binder_object *fp; if (*offp > t->buffer->data_size - sizeof(*fp) || + *offp < off_min || t->buffer->data_size < sizeof(*fp) || !IS_ALIGNED(*offp, sizeof(u32))) { - binder_user_error("%d:%d got transaction with invalid offset, %lld\n", - proc->pid, thread->pid, (u64)*offp); + binder_user_error("%d:%d got transaction with invalid offset, %lld (min %lld, max %lld)\n", + proc->pid, thread->pid, (u64)*offp, + (u64)off_min, + (u64)(t->buffer->data_size - + sizeof(*fp))); return_error = BR_FAILED_REPLY; goto err_bad_offset; } fp = (struct flat_binder_object *)(t->buffer->data + *offp); + off_min = *offp + sizeof(struct flat_binder_object); switch (fp->type) { case BINDER_TYPE_BINDER: case BINDER_TYPE_WEAK_BINDER: { |