mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Serban Constantinescu <serban.constantinescu@arm.com>
To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	kernel-team@android.com, arve@android.com,
	john.stultz@linaro.org, Dave.Butcher@arm.com
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Subject: [PATCH v5 4/6] staging: android: binder: fix alignment issues
Date: Wed, 19 Jun 2013 18:12:34 +0100	[thread overview]
Message-ID: <1371661956-10894-5-git-send-email-serban.constantinescu@arm.com> (raw)
In-Reply-To: <1371661956-10894-1-git-send-email-serban.constantinescu@arm.com>

The Android userspace aligns the data written to the binder buffers to
4bytes. Thus for 32bit platforms or 64bit platforms running an 32bit
Android userspace we can have a buffer looking like this:

platform    buffer(binder_cmd   pointer)      size
32/32                 32b         32b          8B
64/32                 32b         64b          12B
64/64                 32b         64b          12B

Thus the kernel needs to check that the buffer size is aligned to 4bytes
not to (void *) that will be 8bytes on 64bit machines.

The change does not affect existing 32bit ABI.

Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
---
 drivers/staging/android/binder.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index ce70909..7450d56 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -1247,7 +1247,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
 		struct flat_binder_object *fp;
 		if (*offp > buffer->data_size - sizeof(*fp) ||
 		    buffer->data_size < sizeof(*fp) ||
-		    !IS_ALIGNED(*offp, sizeof(void *))) {
+		    !IS_ALIGNED(*offp, sizeof(u32))) {
 			pr_err("transaction release %d bad offset %zd, size %zd\n",
 			 debug_id, *offp, buffer->data_size);
 			continue;
@@ -1496,7 +1496,7 @@ static void binder_transaction(struct binder_proc *proc,
 		struct flat_binder_object *fp;
 		if (*offp > t->buffer->data_size - sizeof(*fp) ||
 		    t->buffer->data_size < sizeof(*fp) ||
-		    !IS_ALIGNED(*offp, sizeof(void *))) {
+		    !IS_ALIGNED(*offp, sizeof(u32))) {
 			binder_user_error("%d:%d got transaction with invalid offset, %zd\n",
 					proc->pid, thread->pid, *offp);
 			return_error = BR_FAILED_REPLY;
-- 
1.7.9.5


  parent reply	other threads:[~2013-06-19 17:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19 17:12 [PATCH v5 0/6] Android Binder IPC Fixes Serban Constantinescu
2013-06-19 17:12 ` [PATCH v5 1/6] staging: android: binder: modify struct binder_write_read to use size_t Serban Constantinescu
2013-06-19 17:12 ` [PATCH v5 2/6] staging: android: binder: fix BINDER_SET_MAX_THREADS declaration Serban Constantinescu
2013-06-19 17:12 ` [PATCH v5 3/6] staging: android: binder: fix BC_FREE_BUFFER ioctl declaration Serban Constantinescu
2013-06-19 17:12 ` Serban Constantinescu [this message]
2013-07-03 22:29   ` [PATCH v5 4/6] staging: android: binder: fix alignment issues Arve Hjønnevåg
2013-06-19 17:12 ` [PATCH v5 5/6] staging: android: binder: replace types with portable ones Serban Constantinescu
2013-07-03 22:30   ` Arve Hjønnevåg
2013-07-04  9:39     ` Serban Constantinescu
2013-06-19 17:12 ` [PATCH v5 6/6] staging: android: binder: fix binder interface for 64bit compat layer Serban Constantinescu
2013-07-03 22:30   ` Arve Hjønnevåg
2013-07-03 16:35 ` [PATCH v5 0/6] Android Binder IPC Fixes Serban Constantinescu
2013-07-03 22:32   ` Arve Hjønnevåg
2013-07-04  9:49     ` Serban Constantinescu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1371661956-10894-5-git-send-email-serban.constantinescu@arm.com \
    --to=serban.constantinescu@arm.com \
    --cc=Dave.Butcher@arm.com \
    --cc=arve@android.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.stultz@linaro.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®