diff mbox series

fs-verity: use u64_to_user_ptr()

Message ID 20191231175408.20524-1-ebiggers@kernel.org
State Accepted
Headers show
Series fs-verity: use u64_to_user_ptr() | expand

Commit Message

Eric Biggers Dec. 31, 2019, 5:54 p.m. UTC
From: Eric Biggers <ebiggers@google.com>

<linux/kernel.h> already provides a macro u64_to_user_ptr().
Use it instead of open-coding the two casts.

No change in behavior.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/verity/enable.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Eric Biggers Jan. 14, 2020, 9:33 p.m. UTC | #1
On Tue, Dec 31, 2019 at 11:54:08AM -0600, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> <linux/kernel.h> already provides a macro u64_to_user_ptr().
> Use it instead of open-coding the two casts.
> 
> No change in behavior.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  fs/verity/enable.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/verity/enable.c b/fs/verity/enable.c
> index 1645d6326e32..520db12e2945 100644
> --- a/fs/verity/enable.c
> +++ b/fs/verity/enable.c
> @@ -216,8 +216,7 @@ static int enable_verity(struct file *filp,
>  
>  	/* Get the salt if the user provided one */
>  	if (arg->salt_size &&
> -	    copy_from_user(desc->salt,
> -			   (const u8 __user *)(uintptr_t)arg->salt_ptr,
> +	    copy_from_user(desc->salt, u64_to_user_ptr(arg->salt_ptr),
>  			   arg->salt_size)) {
>  		err = -EFAULT;
>  		goto out;
> @@ -226,8 +225,7 @@ static int enable_verity(struct file *filp,
>  
>  	/* Get the signature if the user provided one */
>  	if (arg->sig_size &&
> -	    copy_from_user(desc->signature,
> -			   (const u8 __user *)(uintptr_t)arg->sig_ptr,
> +	    copy_from_user(desc->signature, u64_to_user_ptr(arg->sig_ptr),
>  			   arg->sig_size)) {
>  		err = -EFAULT;
>  		goto out;

Applied to fscrypt.git#fsverity for 5.6.

- Eric
diff mbox series

Patch

diff --git a/fs/verity/enable.c b/fs/verity/enable.c
index 1645d6326e32..520db12e2945 100644
--- a/fs/verity/enable.c
+++ b/fs/verity/enable.c
@@ -216,8 +216,7 @@  static int enable_verity(struct file *filp,
 
 	/* Get the salt if the user provided one */
 	if (arg->salt_size &&
-	    copy_from_user(desc->salt,
-			   (const u8 __user *)(uintptr_t)arg->salt_ptr,
+	    copy_from_user(desc->salt, u64_to_user_ptr(arg->salt_ptr),
 			   arg->salt_size)) {
 		err = -EFAULT;
 		goto out;
@@ -226,8 +225,7 @@  static int enable_verity(struct file *filp,
 
 	/* Get the signature if the user provided one */
 	if (arg->sig_size &&
-	    copy_from_user(desc->signature,
-			   (const u8 __user *)(uintptr_t)arg->sig_ptr,
+	    copy_from_user(desc->signature, u64_to_user_ptr(arg->sig_ptr),
 			   arg->sig_size)) {
 		err = -EFAULT;
 		goto out;