]> git.baikalelectronics.ru Git - kernel.git/commit
net: cdc_ncm: fix buffer overflow
authorBjørn Mork <bjorn@mork.no>
Fri, 2 May 2014 21:27:00 +0000 (23:27 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 May 2014 19:19:31 +0000 (15:19 -0400)
commit90e74d1da3947b0a9e1b1fbf73d61c297b13650e
treecba3b2ee49afcb899343f01c4de77bf020176e69
parent1922bc5e678867be8cbbfda6ddd449eb34d3ed4c
net: cdc_ncm: fix buffer overflow

Commit b359ff6ad335 ("net: cdc_ncm: no point in filling up the NTBs
if we send ZLPs") changed the padding logic for devices with the ZLP
flag set.  This meant that frames of any size will be sent without
additional padding, except for the single byte added if the size is
a multiple of the USB packet size. But if the unpadded size is
identical to the maximum frame size, and the maximum size is a
multiplum of the USB packet size, then this one-byte padding will
overflow the buffer.

Prevent padding if already at maximum frame size, letting usbnet
transmit a ZLP instead in this case.

Fixes: b359ff6ad335 ("net: cdc_ncm: no point in filling up the NTBs if we send ZLPs")
Reported by: Yu-an Shih <yshih@nvidia.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/cdc_ncm.c