“d0a7e02a0324fc6efc2f7fae27538645e08a2a20”上不存在“source/libs/git@gitcode.net:taosdata/tdengine.git”
提交 768a6670 编写于 作者: P Pavel Skripkin 提交者: Yongqiang Liu

net: mcs7830: handle usb read errors properly

stable inclusion
from linux-4.19.226
commit e0b2cd310d0859907a9a7b4e4ef9a5bcce9d3d6d

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

[ Upstream commit d668769e ]

Syzbot reported uninit value in mcs7830_bind(). The problem was in
missing validation check for bytes read via usbnet_read_cmd().

usbnet_read_cmd() internally calls usb_control_msg(), that returns
number of bytes read. Code should validate that requested number of bytes
was actually read.

So, this patch adds missing size validation check inside
mcs7830_get_reg() to prevent uninit value bugs

Reported-and-tested-by: syzbot+003c0a286b9af5412510@syzkaller.appspotmail.com
Fixes: 2a36d708 ("USB: driver for mcs7830 (aka DeLOCK) USB ethernet adapter")
Signed-off-by: NPavel Skripkin <paskripkin@gmail.com>
Reviewed-by: NArnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20220106225716.7425-1-paskripkin@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
Signed-off-by: NLaibin Qiu <qiulaibin@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 32753944
...@@ -121,8 +121,16 @@ static const char driver_name[] = "MOSCHIP usb-ethernet driver"; ...@@ -121,8 +121,16 @@ static const char driver_name[] = "MOSCHIP usb-ethernet driver";
static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data) static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
{ {
return usbnet_read_cmd(dev, MCS7830_RD_BREQ, MCS7830_RD_BMREQ, int ret;
0x0000, index, data, size);
ret = usbnet_read_cmd(dev, MCS7830_RD_BREQ, MCS7830_RD_BMREQ,
0x0000, index, data, size);
if (ret < 0)
return ret;
else if (ret < size)
return -ENODATA;
return ret;
} }
static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data) static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册