Patch "usb: gadget: f_fs: stricter integer overflow checks" has been added to the 6.0-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

    usb: gadget: f_fs: stricter integer overflow checks

to the 6.0-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:
     usb-gadget-f_fs-stricter-integer-overflow-checks.patch
and it can be found in the queue-6.0 subdirectory.

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



commit 18be4ff72889aac6dbf973007463ab3752c0f680
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Thu Sep 1 17:59:42 2022 +0300

    usb: gadget: f_fs: stricter integer overflow checks
    
    [ Upstream commit f57004b9d96755cd6a243b51c267be4016b4563c ]
    
    This from static analysis.  The vla_item() takes a size and adds it to
    the total.  It has a built in integer overflow check so if it encounters
    an integer overflow anywhere then it records the total as SIZE_MAX.
    
    However there is an issue here because the "lang_count*(needed_count+1)"
    multiplication can overflow.  Technically the "lang_count + 1" addition
    could overflow too, but that would be detected and is harmless.  Fix
    both using the new size_add() and size_mul() functions.
    
    Fixes: e6f3862fa1ec ("usb: gadget: FunctionFS: Remove VLAIS usage from gadget code")
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/YxDI3lMYomE7WCjn@kili
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index e0fa4b186ec6..36184a762527 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2645,10 +2645,10 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
 		unsigned i = 0;
 		vla_group(d);
 		vla_item(d, struct usb_gadget_strings *, stringtabs,
-			lang_count + 1);
+			size_add(lang_count, 1));
 		vla_item(d, struct usb_gadget_strings, stringtab, lang_count);
 		vla_item(d, struct usb_string, strings,
-			lang_count*(needed_count+1));
+			size_mul(lang_count, (needed_count + 1)));
 
 		char *vlabuf = kmalloc(vla_group_size(d), GFP_KERNEL);
 



[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