Skip to contentSkip to conversation

fs-verity: use u64_to_user_ptr()

PATCH Applied Eric Biggers 1 participant 2 messages Dec 31, 2019 – Jan 14, 2020

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 fs-verity: use u64_to_user_ptr()

From: Eric Biggers <[email protected]>

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

No change in behavior.

---
 fs/verity/enable.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/verity/enable.c +2 -4
index 1645d6326e32..520db12e2945 100644
@@ -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;
Signature · 1 line
2.24.1
author maintainer Applied
#1 lore raw
Quoted 27 lines · Eric Biggers

From: Eric Biggers <[email protected]>

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

No change in behavior.

---
 fs/verity/enable.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/verity/enable.c +1 -2
index 1645d6326e32..520db12e2945 100644
@@ -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;

fs/verity/enable.c static int enable_verity(struct file *filp, · line 231

Quoted 9 lines
fs/verity/enable.c +1 -2
@@ -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