Patch "gpio: sim: fix memory corruption when adding named lines and unnamed hogs" has been added to the 6.1-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

    gpio: sim: fix memory corruption when adding named lines and unnamed hogs

to the 6.1-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:
     gpio-sim-fix-memory-corruption-when-adding-named-lin.patch
and it can be found in the queue-6.1 subdirectory.

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



commit 5629b6671f4eceffbbf5b7190919516547a74c35
Author: Kent Gibson <warthog618@xxxxxxxxx>
Date:   Tue Jun 6 20:00:34 2023 +0800

    gpio: sim: fix memory corruption when adding named lines and unnamed hogs
    
    [ Upstream commit 95ae9979bfe3174c2ee8d64409c44532f2881907 ]
    
    When constructing the sim, gpio-sim constructs an array of named lines,
    sized based on the largest offset of any named line, and then initializes
    that array with the names of all lines, including unnamed hogs with higher
    offsets.  In doing so it writes NULLs beyond the extent of the array.
    
    Add a check that only named lines are used to initialize the array.
    
    Fixes: cb8c474e79be ("gpio: sim: new testing module")
    Signed-off-by: Kent Gibson<warthog618@xxxxxxxxx>
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index cff68f31a09fd..803676e307d73 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -717,8 +717,10 @@ static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank,
 	if (!line_names)
 		return ERR_PTR(-ENOMEM);
 
-	list_for_each_entry(line, &bank->line_list, siblings)
-		line_names[line->offset] = line->name;
+	list_for_each_entry(line, &bank->line_list, siblings) {
+		if (line->name && (line->offset <= max_offset))
+			line_names[line->offset] = line->name;
+	}
 
 	return line_names;
 }



[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