Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1996895 authored by Dan Carpenter's avatar Dan Carpenter Committed by Martijn Coenen
Browse files

UPSTREAM: 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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarMartijn Coenen <maco@android.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 361f2ddbb0c9f9b4f336025a7bd0212cea4a34f0)

Change-Id: I098d525ba63d125caa9840e6e1d5004bf70edc3c
parent dd5682ce
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2214,8 +2214,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;