* [PATCH] cxl/mem: return -EFAULT if copy_to_user() fails
@ 2021-02-19 9:54 Dan Carpenter
2021-02-19 15:39 ` Dan Williams
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-02-19 9:54 UTC (permalink / raw)
To: Alison Schofield, Ben Widawsky
Cc: Vishal Verma, Ira Weiny, Dan Williams, linux-cxl, linux-kernel,
kernel-janitors
The copy_to_user() function returns the number of bytes remaining to be
copied, but we want to return -EFAULT if the copy doesn't complete.
Fixes: b754ffbbc0ee ("cxl/mem: Add basic IOCTL interface")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/cxl/mem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
index 8331a2fc7667..d73ab363ad71 100644
--- a/drivers/cxl/mem.c
+++ b/drivers/cxl/mem.c
@@ -745,7 +745,10 @@ static int cxl_send_cmd(struct cxl_memdev *cxlmd,
if (rc)
return rc;
- return copy_to_user(s, &send, sizeof(send));
+ if (copy_to_user(s, &send, sizeof(send)))
+ return -EFAULT;
+
+ return 0;
}
static long __cxl_memdev_ioctl(struct cxl_memdev *cxlmd, unsigned int cmd,
--
2.30.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] cxl/mem: return -EFAULT if copy_to_user() fails
2021-02-19 9:54 [PATCH] cxl/mem: return -EFAULT if copy_to_user() fails Dan Carpenter
@ 2021-02-19 15:39 ` Dan Williams
0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2021-02-19 15:39 UTC (permalink / raw)
To: Dan Carpenter
Cc: Alison Schofield, Ben Widawsky, Vishal Verma, Ira Weiny,
linux-cxl, Linux Kernel Mailing List, kernel-janitors
On Fri, Feb 19, 2021 at 1:55 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The copy_to_user() function returns the number of bytes remaining to be
> copied, but we want to return -EFAULT if the copy doesn't complete.
>
> Fixes: b754ffbbc0ee ("cxl/mem: Add basic IOCTL interface")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
Looks good, Dan, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-19 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 9:54 [PATCH] cxl/mem: return -EFAULT if copy_to_user() fails Dan Carpenter
2021-02-19 15:39 ` Dan Williams
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®