Skip to content

Commit 1e5cab5

Browse files
Jeimongregkh
authored andcommitted
net/nfc/rawsock.c: fix a permission check bug
[ Upstream commit 8ab7886 ] 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: Jeimon <jjjinmeng.zhou@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 584b2c7 commit 1e5cab5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎net/nfc/rawsock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static int rawsock_create(struct net *net, struct socket *sock,
329329
return -ESOCKTNOSUPPORT;
330330

331331
if (sock->type == SOCK_RAW) {
332-
if (!capable(CAP_NET_RAW))
332+
if (!ns_capable(net->user_ns, CAP_NET_RAW))
333333
return -EPERM;
334334
sock->ops = &rawsock_raw_ops;
335335
} else {

0 commit comments

Comments
 (0)