diff mbox

[12/14] staging: binder: Fix ABI for 64bit Android

Message ID 1392674322-9036-13-git-send-email-john.stultz@linaro.org
State Superseded
Headers show

Commit Message

John Stultz Feb. 17, 2014, 9:58 p.m. UTC
From: Serban Constantinescu <serban.constantinescu@arm.com>

This patch fixes the ABI for 64bit Android userspace.
BC_REQUEST_DEATH_NOTIFICATION and BC_CLEAR_DEATH_NOTIFICATION claim
to be using struct binder_ptr_cookie, but they are using a 32bit handle
and a pointer.

On 32bit systems the payload size is the same as the size of struct
binder_ptr_cookie, however for 64bit systems this will differ. This
patch adds struct binder_handle_cookie that fixes this issue for 64bit
Android.

Since there are no 64bit users of this interface that we know of this
change should not affect any existing systems.

Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Colin Cross <ccross@android.com>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Serban Constantinescu <serban.constantinescu@arm.com>
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
[jstultz: Minor commit tweaks, few 80+ col fixes for checkpatch]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/staging/android/uapi/binder.h | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

John Stultz Feb. 18, 2014, 7:30 p.m. UTC | #1
On Tue, Feb 18, 2014 at 11:08 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Mon, Feb 17, 2014 at 01:58:40PM -0800, John Stultz wrote:
>> From: Serban Constantinescu <serban.constantinescu@arm.com>
>>
>> This patch fixes the ABI for 64bit Android userspace.
>> BC_REQUEST_DEATH_NOTIFICATION and BC_CLEAR_DEATH_NOTIFICATION claim
>> to be using struct binder_ptr_cookie, but they are using a 32bit handle
>> and a pointer.
>>
>> On 32bit systems the payload size is the same as the size of struct
>> binder_ptr_cookie, however for 64bit systems this will differ. This
>> patch adds struct binder_handle_cookie that fixes this issue for 64bit
>> Android.
>>
>> Since there are no 64bit users of this interface that we know of this
>> change should not affect any existing systems.
>
> But you are changing the ioctl structures here, what is that going to
> cause with old programs?

So I'd be glad for Serban or Arve to clarify, but my understanding
(and as is described in the commit message) is that the assumption is
there are no 64bit binder users at this point, and the ioctl structure
changes are made such that existing 32bit applications are unaffected.

>> Cc: Colin Cross <ccross@android.com>
>> Cc: Arve Hjønnevåg <arve@android.com>
>> Cc: Serban Constantinescu <serban.constantinescu@arm.com>
>> Cc: Android Kernel Team <kernel-team@android.com>
>
> I am going to require Acks from someone on the Android team to accept
> this, or any other 64bit binder patch, given all the back-and-forth that
> has happened with the different patch sets here over the past year or
> so.

Certainly reasonable given the earlier back and forth.  For extra
context, these have been merged into the 3.10 AOSP by Arve:
https://android-review.googlesource.com/#/c/79228/

thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
John Stultz Feb. 18, 2014, 8:02 p.m. UTC | #2
On Tue, Feb 18, 2014 at 11:49 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Tue, Feb 18, 2014 at 11:30:26AM -0800, John Stultz wrote:
>> On Tue, Feb 18, 2014 at 11:08 AM, Greg KH <gregkh@linuxfoundation.org> wrote:
>> > On Mon, Feb 17, 2014 at 01:58:40PM -0800, John Stultz wrote:
>> >> From: Serban Constantinescu <serban.constantinescu@arm.com>
>> >>
>> >> This patch fixes the ABI for 64bit Android userspace.
>> >> BC_REQUEST_DEATH_NOTIFICATION and BC_CLEAR_DEATH_NOTIFICATION claim
>> >> to be using struct binder_ptr_cookie, but they are using a 32bit handle
>> >> and a pointer.
>> >>
>> >> On 32bit systems the payload size is the same as the size of struct
>> >> binder_ptr_cookie, however for 64bit systems this will differ. This
>> >> patch adds struct binder_handle_cookie that fixes this issue for 64bit
>> >> Android.
>> >>
>> >> Since there are no 64bit users of this interface that we know of this
>> >> change should not affect any existing systems.
>> >
>> > But you are changing the ioctl structures here, what is that going to
>> > cause with old programs?
>>
>> So I'd be glad for Serban or Arve to clarify, but my understanding
>> (and as is described in the commit message) is that the assumption is
>> there are no 64bit binder users at this point, and the ioctl structure
>> changes are made such that existing 32bit applications are unaffected.
>
> How does changing the structure size, and contents, not affect any
> applications or the kernel code?  What am I missing here?

On 32bit pointers and ints are the same size? (Years ago I sat through
your presentation on this, so I'm worried I'm missing something here
:)

struct binder_ptr_cookie {
void *ptr;
void *cookie;
};

struct binder_handle_cookie {
__u32 handle;
void *cookie;
} __attribute__((packed));


On 32bit systems these are the same size.  Now on 64bit systems, this
changes things, and would break users, but the assumption here is
there are no pre-existing 64bit binder users.


>> >> Cc: Colin Cross <ccross@android.com>
>> >> Cc: Arve Hjønnevåg <arve@android.com>
>> >> Cc: Serban Constantinescu <serban.constantinescu@arm.com>
>> >> Cc: Android Kernel Team <kernel-team@android.com>
>> >
>> > I am going to require Acks from someone on the Android team to accept
>> > this, or any other 64bit binder patch, given all the back-and-forth that
>> > has happened with the different patch sets here over the past year or
>> > so.
>>
>> Certainly reasonable given the earlier back and forth.  For extra
>> context, these have been merged into the 3.10 AOSP by Arve:
>> https://android-review.googlesource.com/#/c/79228/
>
> That's good to see, and a good reason to get them merged, but better
> descriptions and acks would be nice to have :)
>
> How about sending these as a separate series when all worked out, as
> lots of people seem interested in them?

Yep. Will do.

thanks
-john
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/drivers/staging/android/uapi/binder.h b/drivers/staging/android/uapi/binder.h
index 2b1eb81..4071fcf 100644
--- a/drivers/staging/android/uapi/binder.h
+++ b/drivers/staging/android/uapi/binder.h
@@ -152,6 +152,11 @@  struct binder_ptr_cookie {
 	void *cookie;
 };
 
+struct binder_handle_cookie {
+	__u32 handle;
+	void *cookie;
+} __attribute__((packed));
+
 struct binder_pri_desc {
 	__s32 priority;
 	__u32 desc;
@@ -308,15 +313,17 @@  enum binder_driver_command_protocol {
 	 * of looping threads it has available.
 	 */
 
-	BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14, struct binder_ptr_cookie),
+	BC_REQUEST_DEATH_NOTIFICATION = _IOW('c', 14,
+						struct binder_handle_cookie),
 	/*
-	 * void *: ptr to binder
+	 * int: handle
 	 * void *: cookie
 	 */
 
-	BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15, struct binder_ptr_cookie),
+	BC_CLEAR_DEATH_NOTIFICATION = _IOW('c', 15,
+						struct binder_handle_cookie),
 	/*
-	 * void *: ptr to binder
+	 * int: handle
 	 * void *: cookie
 	 */