Skip to contentSkip to conversation

powerpc/pseries: papr-hvpipe: Return -EFAULT on copy_to_user() failure

PATCH New Alper Ak 1 participant 1 message Dec 24, 2025 PowerPC

lore
Share & tools
lore

Alper Ak

author
#0 lore raw

PATCH 1/1 powerpc/pseries: papr-hvpipe: Return -EFAULT on copy_to_user() failure

copy_to_user() returns the number of bytes that could not be copied, not an error code. Currently, hvpipe_rtas_recv_msg() and papr_hvpipe_handle_read() return this positive value directly on failure, which userspace interprets as a successful read of that many bytes.

Return -EFAULT when copy_to_user() fails.

---
 arch/powerpc/platforms/pseries/papr-hvpipe.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/papr-hvpipe.c +4 -2
index dd7b668799d9..0dee94c7c887 100644
@@ -209,7 +209,9 @@ static int hvpipe_rtas_recv_msg(char __user *buf, int size)
 			ret = copy_to_user(buf,
 					rtas_work_area_raw_buf(work_area),
 					bytes_written);
-			if (!ret)
+			if (ret)
+				ret = -EFAULT;
+			else
 				ret = bytes_written;
 		}
 	} else {
@@ -376,7 +378,7 @@ static ssize_t papr_hvpipe_handle_read(struct file *file,
 
 	ret = copy_to_user(buf, &hdr, HVPIPE_HDR_LEN);
 	if (ret)
-		return ret;
+		return -EFAULT;
 
 	/*
 	 * Message event has payload, so get the payload with
Signature · 1 line
2.43.0