提交 be9cb619 编写于 作者: S Szymon Heidrich 提交者: sanglipeng

net: usb: sr9700: Handle negative len

stable inclusion
from stable-v5.10.166
commit 67866b1e0ab9ca7858547c38f8f69d45892e67a8
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7TH9O

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=67866b1e0ab9ca7858547c38f8f69d45892e67a8

--------------------------------

[ Upstream commit ecf7cf8e ]

Packet len computed as difference of length word extracted from
skb data and four may result in a negative value. In such case
processing of the buffer should be interrupted rather than
setting sr_skb->len to an unexpectedly large value (due to cast
from signed to unsigned integer) and passing sr_skb to
usbnet_skb_return.

Fixes: e9da0b56 ("sr9700: sanity check for packet length")
Signed-off-by: NSzymon Heidrich <szymon.heidrich@gmail.com>
Link: https://lore.kernel.org/r/20230114182326.30479-1-szymon.heidrich@gmail.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 45fc9a60
...@@ -410,7 +410,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ...@@ -410,7 +410,7 @@ static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
/* ignore the CRC length */ /* ignore the CRC length */
len = (skb->data[1] | (skb->data[2] << 8)) - 4; len = (skb->data[1] | (skb->data[2] << 8)) - 4;
if (len > ETH_FRAME_LEN || len > skb->len) if (len > ETH_FRAME_LEN || len > skb->len || len < 0)
return 0; return 0;
/* the last packet of current skb */ /* the last packet of current skb */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册