diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2018-03-29 12:14:40 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-23 13:14:37 +0300 |
commit | 361f2ddbb0c9f9b4f336025a7bd0212cea4a34f0 (patch) | |
tree | 148d33131fd6ce99220d633e5d0a7a6941d0ac6f | |
parent | 6d08b06e67cd117f6992c46611dfb4ce267cd71e (diff) | |
download | linux-361f2ddbb0c9f9b4f336025a7bd0212cea4a34f0.tar.xz |
ANDROID: binder: re-order some conditions
It doesn't make any difference to runtime but I've switched these two
checks to make my static checker happy.
The problem is that "buffer->data_size" is user controlled and if it's
less than "sizeo(*hdr)" then that means "offset" can be more than
"buffer->data_size". It's just cleaner to check it in the other order.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Martijn Coenen <maco@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/android/binder.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 764b63a5aade..00322b146469 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -2058,8 +2058,8 @@ static size_t binder_validate_object(struct binder_buffer *buffer, u64 offset) struct binder_object_header *hdr; size_t object_size = 0; - if (offset > buffer->data_size - sizeof(*hdr) || - buffer->data_size < sizeof(*hdr) || + if (buffer->data_size < sizeof(*hdr) || + offset > buffer->data_size - sizeof(*hdr) || !IS_ALIGNED(offset, sizeof(u32))) return 0; |