USB: gadget: f_ncm: add bounds checks to ncm_unwrap_ntb()
authorBrooke Basile <brookebasile@gmail.com>
Tue, 25 Aug 2020 13:07:27 +0000 (09:07 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Sep 2020 09:29:48 +0000 (11:29 +0200)
commitae6a5394d9fbe118bc95cfe376d6a9d91d7547e8
treeaaa3c9c678bbbfd28ce17598ef360324adc847b1
parent480e17846d321f922c22d1d6d418d270c3d89ba4
USB: gadget: f_ncm: add bounds checks to ncm_unwrap_ntb()

commit 2b74b0a04d3e9f9f08ff026e5663dce88ff94e52 upstream.

Some values extracted by ncm_unwrap_ntb() could possibly lead to several
different out of bounds reads of memory.  Specifically the values passed
to netdev_alloc_skb_ip_align() need to be checked so that memory is not
overflowed.

Resolve this by applying bounds checking to a number of different
indexes and lengths of the structure parsing logic.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Brooke Basile <brookebasile@gmail.com>
Acked-by: Felipe Balbi <balbi@kernel.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_ncm.c