diff mbox series

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

Message ID 20210508035230.8229-1-jjjinmeng.zhou@gmail.com (mailing list archive)
State Accepted
Commit 8ab78863e9eff11910e1ac8bcf478060c29b379e
Delegated to: Netdev Maintainers
Headers show
Series net/nfc/rawsock.c: fix a permission check bug | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 3 maintainers not CCed: bianpan2016@163.com mkl@pengutronix.de ieatmuttonchuan@gmail.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Jinmeng Zhou May 8, 2021, 3:52 a.m. UTC
From: Jeimon <jjjinmeng.zhou@gmail.com>

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>
---
 net/nfc/rawsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org May 10, 2021, 9:30 p.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Sat,  8 May 2021 11:52:30 +0800 you wrote:
> From: Jeimon <jjjinmeng.zhou@gmail.com>
> 
> 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>
> ---
>  net/nfc/rawsock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - net/nfc/rawsock.c: fix a permission check bug
    https://git.kernel.org/netdev/net/c/8ab78863e9ef

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index 955c195ae..a76b62f55 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -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 {