CDC-NCM: avoid overflow in sanity checking
authorOliver Neukum <oneukum@suse.com>
Tue, 15 Feb 2022 10:35:47 +0000 (11:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2022 10:47:51 +0000 (11:47 +0100)
commit49909c9f8458cacb5b241106cba65aba5a6d8f4c
tree60de418d9fa71348c4ec0376aec25c61a0f0d8e0
parent4b77aab7ada70bb3a78ffb4dd29b297f311e7fc2
CDC-NCM: avoid overflow in sanity checking

commit 8d2b1a1ec9f559d30b724877da4ce592edc41fdc upstream.

A broken device may give an extreme offset like 0xFFF0
and a reasonable length for a fragment. In the sanity
check as formulated now, this will create an integer
overflow, defeating the sanity check. Both offset
and offset + len need to be checked in such a manner
that no overflow can occur.
And those quantities should be unsigned.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/usb/cdc_ncm.c