Patch "pinctrl: stm32: fix array read out of bound" has been added to the 6.6-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

    pinctrl: stm32: fix array read out of bound

to the 6.6-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:
     pinctrl-stm32-fix-array-read-out-of-bound.patch
and it can be found in the queue-6.6 subdirectory.

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



commit 1fefc60e7041a503dee13ae5fb493e73369a6ae5
Author: Antonio Borneo <antonio.borneo@xxxxxxxxxxx>
Date:   Tue Nov 7 12:05:20 2023 +0100

    pinctrl: stm32: fix array read out of bound
    
    [ Upstream commit edd48fd9d45370d6c8ba0dd834fcc51ff688cc87 ]
    
    The existing code does not verify if the "tentative" index exceeds
    the size of the array, causing out of bound read.
    Issue identified with kasan.
    
    Check the index before using it.
    
    Signed-off-by: Antonio Borneo <antonio.borneo@xxxxxxxxxxx>
    Fixes: 32c170ff15b0 ("pinctrl: stm32: set default gpio line names using pin names")
    Link: https://lore.kernel.org/r/20231107110520.4449-1-antonio.borneo@xxxxxxxxxxx
    Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 419eca49ccecb..346a31f31bba8 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -1283,9 +1283,11 @@ static struct stm32_desc_pin *stm32_pctrl_get_desc_pin_from_gpio(struct stm32_pi
 	int i;
 
 	/* With few exceptions (e.g. bank 'Z'), pin number matches with pin index in array */
-	pin_desc = pctl->pins + stm32_pin_nb;
-	if (pin_desc->pin.number == stm32_pin_nb)
-		return pin_desc;
+	if (stm32_pin_nb < pctl->npins) {
+		pin_desc = pctl->pins + stm32_pin_nb;
+		if (pin_desc->pin.number == stm32_pin_nb)
+			return pin_desc;
+	}
 
 	/* Otherwise, loop all array to find the pin with the right number */
 	for (i = 0; i < pctl->npins; i++) {



[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