* [PATCH] powerpc/pseries: papr-hvpipe: Return -EFAULT on copy_to_user() failure
@ 2025-12-24 8:31 Alper Ak
0 siblings, 0 replies; only message in thread
From: Alper Ak @ 2025-12-24 8:31 UTC (permalink / raw)
To: linuxppc-dev, linux-kernel
Cc: Alper Ak, kernel test robot, Dan Carpenter, Madhavan Srinivasan,
Michael Ellerman, Nicholas Piggin, Christophe Leroy (CS GROUP),
Tyrel Datwyler, Mahesh Salgaonkar, Haren Myneni,
Christian Brauner
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.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202512240028.EKDG3Wu6-lkp@intel.com/
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
arch/powerpc/platforms/pseries/papr-hvpipe.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/platforms/pseries/papr-hvpipe.c
index dd7b668799d9..0dee94c7c887 100644
--- a/arch/powerpc/platforms/pseries/papr-hvpipe.c
+++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c
@@ -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
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-24 8:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-24 8:31 [PATCH] powerpc/pseries: papr-hvpipe: Return -EFAULT on copy_to_user() failure Alper Ak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®