Patch "iio: health: afe4403: Fix oob read in afe4403_read_raw" has been added to the 4.9-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

    iio: health: afe4403: Fix oob read in afe4403_read_raw

to the 4.9-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:
     iio-health-afe4403-fix-oob-read-in-afe4403_read_raw.patch
and it can be found in the queue-4.9 subdirectory.

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



commit c69740cf4b9e6b5fdb778c174044855a95698c40
Author: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
Date:   Mon Nov 7 15:19:46 2022 +0000

    iio: health: afe4403: Fix oob read in afe4403_read_raw
    
    [ Upstream commit 58143c1ed5882c138a3cd2251a336fc8755f23d9 ]
    
    KASAN report out-of-bounds read as follows:
    
    BUG: KASAN: global-out-of-bounds in afe4403_read_raw+0x42e/0x4c0
    Read of size 4 at addr ffffffffc02ac638 by task cat/279
    
    Call Trace:
     afe4403_read_raw
     iio_read_channel_info
     dev_attr_show
    
    The buggy address belongs to the variable:
     afe4403_channel_leds+0x18/0xffffffffffffe9e0
    
    This issue can be reproduced by singe command:
    
     $ cat /sys/bus/spi/devices/spi0.0/iio\:device0/in_intensity6_raw
    
    The array size of afe4403_channel_leds is less than channels, so access
    with chan->address cause OOB read in afe4403_read_raw. Fix it by moving
    access before use it.
    
    Fixes: b36e8257641a ("iio: health/afe440x: Use regmap fields")
    Signed-off-by: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
    Acked-by: Andrew Davis <afd@xxxxxx>
    Link: https://lore.kernel.org/r/20221107151946.89260-1-weiyongjun@xxxxxxxxxxxxxxx
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
index 2f07c4d1398c..4756e9645f7d 100644
--- a/drivers/iio/health/afe4403.c
+++ b/drivers/iio/health/afe4403.c
@@ -253,14 +253,14 @@ static int afe4403_read_raw(struct iio_dev *indio_dev,
 			    int *val, int *val2, long mask)
 {
 	struct afe4403_data *afe = iio_priv(indio_dev);
-	unsigned int reg = afe4403_channel_values[chan->address];
-	unsigned int field = afe4403_channel_leds[chan->address];
+	unsigned int reg, field;
 	int ret;
 
 	switch (chan->type) {
 	case IIO_INTENSITY:
 		switch (mask) {
 		case IIO_CHAN_INFO_RAW:
+			reg = afe4403_channel_values[chan->address];
 			ret = afe4403_read(afe, reg, val);
 			if (ret)
 				return ret;
@@ -270,6 +270,7 @@ static int afe4403_read_raw(struct iio_dev *indio_dev,
 	case IIO_CURRENT:
 		switch (mask) {
 		case IIO_CHAN_INFO_RAW:
+			field = afe4403_channel_leds[chan->address];
 			ret = regmap_field_read(afe->fields[field], val);
 			if (ret)
 				return ret;



[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