Patch "i2c: mux: harden i2c_mux_alloc() against integer overflows" has been added to the 5.19-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: mux: harden i2c_mux_alloc() against integer overflows

to the 5.19-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-mux-harden-i2c_mux_alloc-against-integer-overflo.patch
and it can be found in the queue-5.19 subdirectory.

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



commit e0a49fbfc479eb41a8df0e03f3304d4b695610ea
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Thu Sep 15 14:30:58 2022 +0300

    i2c: mux: harden i2c_mux_alloc() against integer overflows
    
    [ Upstream commit b7af938f4379a884f15713319648a7653497a907 ]
    
    A couple years back we went through the kernel an automatically
    converted size calculations to use struct_size() instead.  The
    struct_size() calculation is protected against integer overflows.
    
    However it does not make sense to use the result from struct_size()
    for additional math operations as that would negate any safeness.
    
    Fixes: 1f3b69b6b939 ("i2c: mux: Use struct_size() in devm_kzalloc()")
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Acked-by: Peter Rosin <peda@xxxxxxxxxx>
    Reviewed-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
    Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 774507b54b57..313904be5f3b 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -243,9 +243,10 @@ struct i2c_mux_core *i2c_mux_alloc(struct i2c_adapter *parent,
 				   int (*deselect)(struct i2c_mux_core *, u32))
 {
 	struct i2c_mux_core *muxc;
+	size_t mux_size;
 
-	muxc = devm_kzalloc(dev, struct_size(muxc, adapter, max_adapters)
-			    + sizeof_priv, GFP_KERNEL);
+	mux_size = struct_size(muxc, adapter, max_adapters);
+	muxc = devm_kzalloc(dev, size_add(mux_size, sizeof_priv), GFP_KERNEL);
 	if (!muxc)
 		return NULL;
 	if (sizeof_priv)



[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