All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>,
	kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org,
	David Airlie <airlied@linux.ie>, Sean Paul <sean@poorly.run>
Subject: [PATCH] drm: return -EFAULT if copy_one_buf() fails
Date: Tue, 18 Jun 2019 12:56:23 +0000	[thread overview]
Message-ID: <20190618125623.GA24896@mwanda> (raw)

The copy_to_user() function returns the number of bytes remaining to be
copied, but we want to return -EFAULT.  This function is called from
__drm_legacy_infobufs() which expects negative error codes.

Fixes: 5c7640ab6258 ("switch compat_drm_infobufs() to drm_ioctl_kernel()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This goes through Al's tree and not through drm.  Presumably this patch
will just get folded into the original.

 drivers/gpu/drm/drm_bufs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 68dacf8422c6..8ce9d73fab4f 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1351,7 +1351,10 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from)
 				 .size = from->buf_size,
 				 .low_mark = from->low_mark,
 				 .high_mark = from->high_mark};
-	return copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags));
+
+	if (copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags)))
+		return -EFAULT;
+	return 0;
 }
 
 int drm_legacy_infobufs(struct drm_device *dev, void *data,
-- 
2.20.1

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>,
	kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org,
	David Airlie <airlied@linux.ie>, Sean Paul <sean@poorly.run>
Subject: [PATCH] drm: return -EFAULT if copy_one_buf() fails
Date: Tue, 18 Jun 2019 15:56:23 +0300	[thread overview]
Message-ID: <20190618125623.GA24896@mwanda> (raw)

The copy_to_user() function returns the number of bytes remaining to be
copied, but we want to return -EFAULT.  This function is called from
__drm_legacy_infobufs() which expects negative error codes.

Fixes: 5c7640ab6258 ("switch compat_drm_infobufs() to drm_ioctl_kernel()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This goes through Al's tree and not through drm.  Presumably this patch
will just get folded into the original.

 drivers/gpu/drm/drm_bufs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 68dacf8422c6..8ce9d73fab4f 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1351,7 +1351,10 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from)
 				 .size = from->buf_size,
 				 .low_mark = from->low_mark,
 				 .high_mark = from->high_mark};
-	return copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags));
+
+	if (copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags)))
+		return -EFAULT;
+	return 0;
 }
 
 int drm_legacy_infobufs(struct drm_device *dev, void *data,
-- 
2.20.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

             reply	other threads:[~2019-06-18 12:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 12:56 Dan Carpenter [this message]
2019-06-18 12:56 ` [PATCH] drm: return -EFAULT if copy_one_buf() fails Dan Carpenter
2019-06-18 12:58 ` Dan Carpenter
2019-06-18 12:58   ` Dan Carpenter
2019-06-18 13:18 ` [PATCH v2] drm: return -EFAULT if copy_to_user() fails Dan Carpenter
2019-06-18 13:18   ` Dan Carpenter
2019-06-18 13:18   ` Dan Carpenter
2019-06-18 17:16   ` Sean Paul
2019-06-18 17:16     ` Sean Paul
2019-06-18 17:16     ` Sean Paul
2019-06-25 23:18     ` Al Viro
2019-06-25 23:18       ` Al Viro
2019-06-25 23:17 ` [PATCH] drm: return -EFAULT if copy_one_buf() fails Al Viro
2019-06-25 23:17   ` Al Viro

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=20190618125623.GA24896@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=maxime.ripard@bootlin.com \
    --cc=sean@poorly.run \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.