public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] android: binder: fix type mismatch warning
@ 2017-09-05  8:56 Arnd Bergmann
  2017-09-18 14:02 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 16+ messages in thread
From: Arnd Bergmann @ 2017-09-05  8:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Arve Hjønnevåg, Riley Andrews
  Cc: Arnd Bergmann, Todd Kjos, Martijn Coenen, John Stultz, devel,
	linux-kernel

Allowing binder to expose the 64-bit API on 32-bit kernels caused a
build warning:

drivers/android/binder.c: In function 'binder_transaction_buffer_release':
drivers/android/binder.c:2220:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
    fd_array = (u32 *)(parent_buffer + fda->parent_offset);
               ^
drivers/android/binder.c: In function 'binder_translate_fd_array':
drivers/android/binder.c:2445:13: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  fd_array = (u32 *)(parent_buffer + fda->parent_offset);
             ^
drivers/android/binder.c: In function 'binder_fixup_parent':
drivers/android/binder.c:2511:18: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]

This adds extra type casts to avoid the warning.

However, there is another problem with the Kconfig option: turning
it on or off creates two incompatible ABI versions, a kernel that
has this enabled cannot run user space that was built without it
or vice versa. A better solution might be to leave the option hidden
until the binder code is fixed to deal with both ABI versions.

Fixes: e8d2ed7db7c3 ("Revert "staging: Fix build issues with new binder API"")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/android/binder.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index d055b3f2a207..72af95c9ea22 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2217,7 +2217,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
 				       debug_id, (u64)fda->num_fds);
 				continue;
 			}
-			fd_array = (u32 *)(parent_buffer + fda->parent_offset);
+			fd_array = (u32 *)(parent_buffer + (uintptr_t)fda->parent_offset);
 			for (fd_index = 0; fd_index < fda->num_fds; fd_index++)
 				task_close_fd(proc, fd_array[fd_index]);
 		} break;
@@ -2442,7 +2442,7 @@ static int binder_translate_fd_array(struct binder_fd_array_object *fda,
 	 */
 	parent_buffer = parent->buffer -
 		binder_alloc_get_user_buffer_offset(&target_proc->alloc);
-	fd_array = (u32 *)(parent_buffer + fda->parent_offset);
+	fd_array = (u32 *)(parent_buffer + (uintptr_t)fda->parent_offset);
 	if (!IS_ALIGNED((unsigned long)fd_array, sizeof(u32))) {
 		binder_user_error("%d:%d parent offset not aligned correctly.\n",
 				  proc->pid, thread->pid);
@@ -2508,7 +2508,7 @@ static int binder_fixup_parent(struct binder_transaction *t,
 				  proc->pid, thread->pid);
 		return -EINVAL;
 	}
-	parent_buffer = (u8 *)(parent->buffer -
+	parent_buffer = (u8 *)((uintptr_t)parent->buffer -
 			binder_alloc_get_user_buffer_offset(
 				&target_proc->alloc));
 	*(binder_uintptr_t *)(parent_buffer + bp->parent_offset) = bp->buffer;
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-09-22 12:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-05  8:56 [PATCH] android: binder: fix type mismatch warning Arnd Bergmann
2017-09-18 14:02 ` Greg Kroah-Hartman
2017-09-18 15:35   ` Arnd Bergmann
2017-09-18 15:52     ` Christoph Hellwig
2017-09-18 15:53     ` Greg Kroah-Hartman
2017-09-18 16:23       ` Christoph Hellwig
2017-09-18 16:33         ` Greg Kroah-Hartman
2017-09-18 19:49         ` Arnd Bergmann
2017-09-20  9:08           ` Martijn Coenen
2017-09-20  9:58             ` Arnd Bergmann
2017-09-20 10:24               ` Martijn Coenen
2017-09-20 13:37                 ` Arnd Bergmann
2017-09-21  7:44                   ` Greg Kroah-Hartman
2017-09-22  7:00                   ` Martijn Coenen
2017-09-22  9:12                     ` Arnd Bergmann
2017-09-22 12:46                       ` Martijn Coenen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox