Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1383827

Re: [PATCH 2/3] kernel.h: add u64_to_user_ptr()

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] kernel.h: add u64_to_user_ptr()
Date 2016-04-21 03:50 +0200
Message-ID <rqbUJ-S0-1@gated-at.bofh.it> (permalink)
References <rq5Pj-4mv-3@gated-at.bofh.it> <rq5Pk-4mv-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, 2016-04-20 at 16:18 -0300, Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> This function had copies in 3 different files. Unify them in kernel.h.
[]
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
[]
> @@ -53,6 +53,12 @@
> 
>  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
>  
> +static inline void __user *u64_to_user_ptr(u64 address)
> +{
> +	typecheck(u64, address);
> +	return (void __user *)(uintptr_t)address;
> +}
> +

This won't work because by the time address is checked
address is already u64

This would need to be something like

#define u64_to_user_ptr(x)	\
({				\
	typecheck(u64, x);	\
	u64_to_user_ptr(x);	\
})

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/3] kernel.h: add u64_to_user_ptr() Gustavo Padovan <gustavo@padovan.org> - 2016-04-20 21:20 +0200
  Re: [PATCH 2/3] kernel.h: add u64_to_user_ptr() Joe Perches <joe@perches.com> - 2016-04-21 03:50 +0200
    Re: [PATCH 2/3] kernel.h: add u64_to_user_ptr() Gustavo Padovan <gustavo@padovan.org> - 2016-04-21 15:40 +0200

csiph-web