aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2013-09-01 20:11:04 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-26 11:23:01 -0400
commitdd5de1f165ade430357960459491a067c7e3d21c (patch)
tree456a28f27a8945b1025325cc2cf76a59b257c616 /drivers/misc
parente19555ce893f7567c7a72f91dafe6bdb93f0198f (diff)
mei: revamp read and write length checks
1. Return zero on zero length read and writes 2. For a too large write return -EFBIG as defined in man write(2) EFBIG An attempt was made to write a file that exceeds the implementation-defined maximum file size or the process's file size limit, or to write at a position past the maximum allowed offset. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/main.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 5ff810b1e8b3..7404584e65e1 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -203,12 +203,18 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
203 203
204 dev = cl->dev; 204 dev = cl->dev;
205 205
206
206 mutex_lock(&dev->device_lock); 207 mutex_lock(&dev->device_lock);
207 if (dev->dev_state != MEI_DEV_ENABLED) { 208 if (dev->dev_state != MEI_DEV_ENABLED) {
208 rets = -ENODEV; 209 rets = -ENODEV;
209 goto out; 210 goto out;
210 } 211 }
211 212
213 if (length == 0) {
214 rets = 0;
215 goto out;
216 }
217
212 if (cl == &dev->iamthif_cl) { 218 if (cl == &dev->iamthif_cl) {
213 rets = mei_amthif_read(dev, file, ubuf, length, offset); 219 rets = mei_amthif_read(dev, file, ubuf, length, offset);
214 goto out; 220 goto out;
@@ -350,8 +356,14 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
350 rets = -ENODEV; 356 rets = -ENODEV;
351 goto out; 357 goto out;
352 } 358 }
353 if (length > dev->me_clients[id].props.max_msg_length || length <= 0) { 359
354 rets = -EMSGSIZE; 360 if (length == 0) {
361 rets = 0;
362 goto out;
363 }
364
365 if (length > dev->me_clients[id].props.max_msg_length) {
366 rets = -EFBIG;
355 goto out; 367 goto out;
356 } 368 }
357 369