提交 e2827ad9 编写于 作者: E Eric Dumazet 提交者: Zheng Zengkai

llc: fix netdevice reference leaks in llc_ui_bind()

stable inclusion
from stable-v5.10.109
commit 571df3393f523b59cba87e2f3e80a3a624030f9c
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I51YBN
CVE: CVE-2022-28356

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

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

commit 764f4eb6 upstream.

Whenever llc_ui_bind() and/or llc_ui_autobind()
took a reference on a netdevice but subsequently fail,
they must properly release their reference
or risk the infamous message from unregister_netdevice()
at device dismantle.

unregister_netdevice: waiting for eth0 to become free. Usage count = 3

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: NEric Dumazet <edumazet@google.com>
Reported-by: N赵子轩 <beraphin@gmail.com>
Reported-by: NStoyan Manolov <smanolov@suse.de>
Link: https://lore.kernel.org/r/20220323004147.1990845-1-eric.dumazet@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NHuang Guobin <huangguobin4@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 81d82781
......@@ -311,6 +311,10 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
sock_reset_flag(sk, SOCK_ZAPPED);
rc = 0;
out:
if (rc) {
dev_put(llc->dev);
llc->dev = NULL;
}
return rc;
}
......@@ -409,6 +413,10 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
out_put:
llc_sap_put(sap);
out:
if (rc) {
dev_put(llc->dev);
llc->dev = NULL;
}
release_sock(sk);
return rc;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册