提交 0b9b7480 编写于 作者: J Jeimon 提交者: Wang ShaoBo

net/nfc/rawsock.c: fix a permission check bug

stable inclusion
from stable-v5.10.44
commit 1e5cab50208c8fb7351b798cb1d569debfeb994a
bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=371
CVE: NA

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

[ Upstream commit 8ab78863 ]

The function rawsock_create() calls a privileged function sk_alloc(),
which requires a ns-aware check to check net->user_ns, i.e., ns_capable().
However, the original code checks the init_user_ns using capable().
So we replace the capable() with ns_capable().
Signed-off-by: NJeimon <jjjinmeng.zhou@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: lf搁不了浅's avatarlf <15042944259@163.com>
Reviewed-by: Jian Cheng <cj.chengjian(a)huawei.com>
上级 789459f3
......@@ -329,7 +329,7 @@ static int rawsock_create(struct net *net, struct socket *sock,
return -ESOCKTNOSUPPORT;
if (sock->type == SOCK_RAW) {
if (!capable(CAP_NET_RAW))
if (!ns_capable(net->user_ns, CAP_NET_RAW))
return -EPERM;
sock->ops = &rawsock_raw_ops;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册