wifi: libertas: fix integer underflow in process_cmdrequest()
PATCH 1/1 wifi: libertas: fix integer underflow in process_cmdrequest()
The existing validation only checks if recvlength exceeds LBS_CMD_BUFFER_SIZE, but doesn't check the lower bound. When a USB device sends a response shorter than MESSAGE_HEADER_LEN, the subtraction (recvlength - MESSAGE_HEADER_LEN) wraps to a huge value, causing memcpy to corrupt the heap.
Add the same lower bound check that libertas_tf already has.
Signed-off-by Amir Mohammad Jahangirzad <[email protected]>
--- drivers/net/wireless/marvell/libertas/if_usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/marvell/libertas/if_usb.c +3 -2
@@ -625,9 +625,10 @@ static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff,unsigned long flags;u8 i; -if (recvlength >LBS_CMD_BUFFER_SIZE ) { +if (recvlength <MESSAGE_HEADER_LEN || + recvlength >LBS_CMD_BUFFER_SIZE ) {lbs_deb_usbd (&cardp->udev->dev, -"The receive buffer is too large\n" ); +"The receive buffer is invalid: %d\n" , recvlength);kfree_skb (skb);return ; }
Signature · 1 line
2.53.0