Patch "i2c: bail out early when RDWR parameters are wrong" has been added to the 5.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    i2c: bail out early when RDWR parameters are wrong

to the 5.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     i2c-bail-out-early-when-rdwr-parameters-are-wrong.patch
and it can be found in the queue-5.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9943a3cff7543c3cd279311c1c950a10bafbdc14
Author: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
Date:   Fri Mar 12 12:57:34 2021 +0100

    i2c: bail out early when RDWR parameters are wrong
    
    [ Upstream commit 71581562ee36032d2d574a9b23ad4af6d6a64cf7 ]
    
    The buggy parameters currently get caught later, but emit a noisy WARN.
    Userspace should not be able to trigger this, so add similar checks much
    earlier. Also avoids some unneeded code paths, of course. Apply kernel
    coding stlye to a comment while here.
    
    Reported-by: syzbot+ffb0b3ffa6cfbc7d7b3f@xxxxxxxxxxxxxxxxxxxxxxxxx
    Tested-by: syzbot+ffb0b3ffa6cfbc7d7b3f@xxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 6ceb11cc4be1..6ef38a8ee95c 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -440,8 +440,13 @@ static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 				   sizeof(rdwr_arg)))
 			return -EFAULT;
 
-		/* Put an arbitrary limit on the number of messages that can
-		 * be sent at once */
+		if (!rdwr_arg.msgs || rdwr_arg.nmsgs == 0)
+			return -EINVAL;
+
+		/*
+		 * Put an arbitrary limit on the number of messages that can
+		 * be sent at once
+		 */
 		if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
 			return -EINVAL;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux