Skip to contentSkip to conversation

mei: report consistently copy_from/to_user failures

PATCH In review Tomas Winkler 2 participants 3 messages Mar 12, 2014 – Mar 18, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 3/3 mei: report consistently copy_from/to_user failures

From: Alexander Usyskin <[email protected]>

Consistently display error on possible copy_from/to_user failures use dev_dbg so it cannot be abused to flood the kernel log

Reviewed-on: https://git-isdc.jer.intel.com/gerrit/1158
---
V2: use dev_dbg instead of dev_err

 drivers/misc/mei/amthif.c | 4 +++-
 drivers/misc/mei/main.c   | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/misc/mei/amthif.c +3 -1
index b75a7da..2052609 100644
@@ -244,8 +244,10 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
 	 * the buf_idx may point beyond */
 	length = min_t(size_t, length, (cb->buf_idx - *offset));
 
-	if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length))
+	if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
+		dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
 		rets = -EFAULT;
+	}
 	else {
 		rets = length;
 		if ((*offset + length) < cb->buf_idx) {
drivers/misc/mei/main.c +3 -2
index 4e069b8..bc1c39e 100644
@@ -280,6 +280,7 @@ copy_buffer:
 	length = min_t(size_t, length, cb->buf_idx - *offset);
 
 	if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
+		dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
 		rets = -EFAULT;
 		goto free;
 	}
@@ -400,7 +401,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 
 	rets = copy_from_user(write_cb->request_buffer.data, ubuf, length);
 	if (rets) {
-		dev_err(&dev->pdev->dev, "failed to copy data from userland\n");
+		dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
 		rets = -EFAULT;
 		goto out;
 	}
@@ -565,7 +566,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
 	dev_dbg(&dev->pdev->dev, "copy connect data from user\n");
 	if (copy_from_user(connect_data, (char __user *)data,
 				sizeof(struct mei_connect_client_data))) {
-		dev_err(&dev->pdev->dev, "failed to copy data from userland\n");
+		dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
 		rets = -EFAULT;
 		goto out;
 	}
Signature · 1 line
1.8.5.3
#2 lore raw
Quoted 7 lines · Tomas Winkler
Quoted 5 lines

From: Alexander Usyskin <[email protected]>

Consistently display error on possible copy_from/to_user failures use dev_dbg so it cannot be abused to flood the kernel log

Quoted 6 lines
Quoted 3 lines

Reviewed-on: https://git-isdc.jer.intel.com/gerrit/1158

That's a non-public URL, so it doesn't make sense to be put into a kernel changelog :(

Yep, sorry for that, something went wrong with my cleanup script, shall I resubmit or can you remove it by hand.

Thanks
Tomas