The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drivers/comedi: copy userspace array safely
@ 2023-11-02 19:08 Philipp Stanner
  2023-11-03  5:53 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Philipp Stanner @ 2023-11-02 19:08 UTC (permalink / raw)
  To: Ian Abbott, H Hartley Sweeten, Greg Kroah-Hartman,
	Philipp Stanner, Ivan Orlov, Benjamin Tissoires
  Cc: linux-kernel, Dave Airlie

comedi_fops.c utilizes memdup_user() to copy a userspace array. This
does not check for an overflow.

Use the new wrapper memdup_array_user() to copy the array more safely.

Suggested-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Philipp Stanner <pstanner@redhat.com>
---
 drivers/comedi/comedi_fops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
index 1548dea15df1..1b481731df96 100644
--- a/drivers/comedi/comedi_fops.c
+++ b/drivers/comedi/comedi_fops.c
@@ -1714,8 +1714,8 @@ static int __comedi_get_user_chanlist(struct comedi_device *dev,
 
 	lockdep_assert_held(&dev->mutex);
 	cmd->chanlist = NULL;
-	chanlist = memdup_user(user_chanlist,
-			       cmd->chanlist_len * sizeof(unsigned int));
+	chanlist = memdup_array_user(user_chanlist,
+				     cmd->chanlist_len, sizeof(unsigned int));
 	if (IS_ERR(chanlist))
 		return PTR_ERR(chanlist);
 
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-03 10:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02 19:08 [PATCH] drivers/comedi: copy userspace array safely Philipp Stanner
2023-11-03  5:53 ` Greg Kroah-Hartman
2023-11-03  9:11   ` Philipp Stanner
2023-11-03 10:25     ` Ian Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox