2021-12-07 12:25:11

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] binder: fix pointer cast warning

From: Arnd Bergmann <[email protected]>

binder_uintptr_t is not the same as uintptr_t, so converting it into a
pointer requires a second cast:

drivers/android/binder.c: In function 'binder_translate_fd_array':
drivers/android/binder.c:2511:28: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
2511 | sender_ufda_base = (void __user *)sender_uparent->buffer + fda->parent_offset;
| ^

Fixes: 656e01f3ab54 ("binder: read pre-translated fds from sender buffer")
Signed-off-by: Arnd Bergmann <[email protected]>
---
drivers/android/binder.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 5497797ab258..182bb4221b06 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2508,7 +2508,8 @@ static int binder_translate_fd_array(struct list_head *pf_head,
*/
fda_offset = (parent->buffer - (uintptr_t)t->buffer->user_data) +
fda->parent_offset;
- sender_ufda_base = (void __user *)sender_uparent->buffer + fda->parent_offset;
+ sender_ufda_base = (void __user *)(uintptr_t)sender_uparent->buffer +
+ fda->parent_offset;

if (!IS_ALIGNED((unsigned long)fda_offset, sizeof(u32)) ||
!IS_ALIGNED((unsigned long)sender_ufda_base, sizeof(u32))) {
--
2.29.2



2021-12-07 16:51:44

by Todd Kjos

[permalink] [raw]
Subject: Re: [PATCH] binder: fix pointer cast warning

On Tue, Dec 7, 2021 at 4:25 AM Arnd Bergmann <[email protected]> wrote:
>
> From: Arnd Bergmann <[email protected]>
>
> binder_uintptr_t is not the same as uintptr_t, so converting it into a
> pointer requires a second cast:
>
> drivers/android/binder.c: In function 'binder_translate_fd_array':
> drivers/android/binder.c:2511:28: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> 2511 | sender_ufda_base = (void __user *)sender_uparent->buffer + fda->parent_offset;
> | ^
>
> Fixes: 656e01f3ab54 ("binder: read pre-translated fds from sender buffer")
> Signed-off-by: Arnd Bergmann <[email protected]>

Acked-by: Todd Kjos <[email protected]>

> ---
> drivers/android/binder.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 5497797ab258..182bb4221b06 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -2508,7 +2508,8 @@ static int binder_translate_fd_array(struct list_head *pf_head,
> */
> fda_offset = (parent->buffer - (uintptr_t)t->buffer->user_data) +
> fda->parent_offset;
> - sender_ufda_base = (void __user *)sender_uparent->buffer + fda->parent_offset;
> + sender_ufda_base = (void __user *)(uintptr_t)sender_uparent->buffer +
> + fda->parent_offset;
>
> if (!IS_ALIGNED((unsigned long)fda_offset, sizeof(u32)) ||
> !IS_ALIGNED((unsigned long)sender_ufda_base, sizeof(u32))) {
> --
> 2.29.2
>

2021-12-08 10:09:42

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH] binder: fix pointer cast warning

On Tue, Dec 07, 2021 at 01:24:42PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <[email protected]>
>
> binder_uintptr_t is not the same as uintptr_t, so converting it into a
> pointer requires a second cast:
>
> drivers/android/binder.c: In function 'binder_translate_fd_array':
> drivers/android/binder.c:2511:28: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> 2511 | sender_ufda_base = (void __user *)sender_uparent->buffer + fda->parent_offset;
> | ^
>
> Fixes: 656e01f3ab54 ("binder: read pre-translated fds from sender buffer")
> Signed-off-by: Arnd Bergmann <[email protected]>
> ---

Looks good.
Acked-by: Christian Brauner <[email protected]>

2021-12-08 15:00:09

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH] binder: fix pointer cast warning



On 12/8/21 02:09, Christian Brauner wrote:
> On Tue, Dec 07, 2021 at 01:24:42PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <[email protected]>
>>
>> binder_uintptr_t is not the same as uintptr_t, so converting it into a
>> pointer requires a second cast:
>>
>> drivers/android/binder.c: In function 'binder_translate_fd_array':
>> drivers/android/binder.c:2511:28: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>> 2511 | sender_ufda_base = (void __user *)sender_uparent->buffer + fda->parent_offset;
>> | ^
>>
>> Fixes: 656e01f3ab54 ("binder: read pre-translated fds from sender buffer")
>> Signed-off-by: Arnd Bergmann <[email protected]>
>> ---
>
> Looks good.
> Acked-by: Christian Brauner <[email protected]>
>

Acked-by: Randy Dunlap <[email protected]> # build-tested

thanks.

--
~Randy