提交 cf121c46 编写于 作者: H Hangyu Hua 提交者: Zheng Zengkai

usb: gadget: clear related members when goto fail

mainline inclusion
from mainline-v5.17-rc1
commit 501e38a5
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I4U74M
CVE: CVE-2022-24958

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

dev->config and dev->hs_config and dev->dev need to be cleaned if
dev_config fails to avoid UAF.
Acked-by: NAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: NHangyu Hua <hbh25y@gmail.com>
Link: https://lore.kernel.org/r/20211231172138.7993-3-hbh25y@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYuan Can <yuancan@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 aca7de94
...@@ -1876,8 +1876,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) ...@@ -1876,8 +1876,8 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
value = usb_gadget_probe_driver(&gadgetfs_driver); value = usb_gadget_probe_driver(&gadgetfs_driver);
if (value != 0) { if (value != 0) {
kfree (dev->buf); spin_lock_irq(&dev->lock);
dev->buf = NULL; goto fail;
} else { } else {
/* at this point "good" hardware has for the first time /* at this point "good" hardware has for the first time
* let the USB the host see us. alternatively, if users * let the USB the host see us. alternatively, if users
...@@ -1894,6 +1894,9 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) ...@@ -1894,6 +1894,9 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
return value; return value;
fail: fail:
dev->config = NULL;
dev->hs_config = NULL;
dev->dev = NULL;
spin_unlock_irq (&dev->lock); spin_unlock_irq (&dev->lock);
pr_debug ("%s: %s fail %zd, %p\n", shortname, __func__, value, dev); pr_debug ("%s: %s fail %zd, %p\n", shortname, __func__, value, dev);
kfree (dev->buf); kfree (dev->buf);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册