From: Alper Ak <alperyasinak1@gmail.com>
To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: Alper Ak <alperyasinak1@gmail.com>,
kernel test robot <lkp@intel.com>,
Dan Carpenter <error27@gmail.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
Tyrel Datwyler <tyreld@linux.ibm.com>,
Mahesh Salgaonkar <mahesh@linux.ibm.com>,
Haren Myneni <haren@linux.ibm.com>,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH] powerpc/pseries: papr-hvpipe: Return -EFAULT on copy_to_user() failure
Date: Wed, 24 Dec 2025 11:31:10 +0300 [thread overview]
Message-ID: <20251224083116.23904-1-alperyasinak1@gmail.com> (raw)
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
reply other threads:[~2025-12-24 8:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251224083116.23904-1-alperyasinak1@gmail.com \
--to=alperyasinak1@gmail.com \
--cc=brauner@kernel.org \
--cc=chleroy@kernel.org \
--cc=error27@gmail.com \
--cc=haren@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lkp@intel.com \
--cc=maddy@linux.ibm.com \
--cc=mahesh@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=tyreld@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®