]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: potential integer overflow in usbg_make_tpg()
authorChen Yufeng <chenyufeng@iie.ac.cn>
Tue, 15 Apr 2025 06:58:57 +0000 (14:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 6 Jul 2025 09:00:07 +0000 (11:00 +0200)
commita33f507f36d5881f602dab581ab0f8d22b49762c
treed571050defb5315a544c49dbde08a22d281c6f57
parenta8d1b4f219e8833130927f19d1c8bfbf49215ce4
usb: potential integer overflow in usbg_make_tpg()

[ Upstream commit 153874010354d050f62f8ae25cbb960c17633dc5 ]

The variable tpgt in usbg_make_tpg() is defined as unsigned long and is
assigned to tpgt->tport_tpgt, which is defined as u16. This may cause an
integer overflow when tpgt is greater than USHRT_MAX (65535). I
haven't tried to trigger it myself, but it is possible to trigger it
by calling usbg_make_tpg() with a large value for tpgt.

I modified the type of tpgt to match tpgt->tport_tpgt and adjusted the
relevant code accordingly.

This patch is similar to commit 59c816c1f24d ("vhost/scsi: potential
memory corruption").

Signed-off-by: Chen Yufeng <chenyufeng@iie.ac.cn>
Link: https://lore.kernel.org/r/20250415065857.1619-1-chenyufeng@iie.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/gadget/function/f_tcm.c