Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] nfc: enforce CAP_NET_RAW for raw sockets When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first.
@ 2020-08-06  2:28 Qingyu Li
  2020-08-06 18:30 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Qingyu Li @ 2020-08-06  2:28 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel

Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com>
---
 net/nfc/rawsock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
index ba5ffd3badd3..c1302b689a98 100644
--- a/net/nfc/rawsock.c
+++ b/net/nfc/rawsock.c
@@ -332,8 +332,11 @@ static int rawsock_create(struct net *net, struct socket *sock,
 	if ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW))
 		return -ESOCKTNOSUPPORT;

-	if (sock->type == SOCK_RAW)
+	if (sock->type == SOCK_RAW){
+		if (!capable(CAP_NET_RAW))
+			return -EPERM;
 		sock->ops = &rawsock_raw_ops;
+	}
 	else
 		sock->ops = &rawsock_ops;




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfc: enforce CAP_NET_RAW for raw sockets When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first.
  2020-08-06  2:28 [PATCH] nfc: enforce CAP_NET_RAW for raw sockets When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first Qingyu Li
@ 2020-08-06 18:30 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2020-08-06 18:30 UTC (permalink / raw)
  To: Qingyu Li; +Cc: davem, netdev, linux-kernel

On Thu, 6 Aug 2020 10:28:08 +0800 Qingyu Li wrote:

Commit message is required. Perhaps shorten the subject and put more
info here.

> Signed-off-by: Qingyu Li <ieatmuttonchuan@gmail.com>
> ---
>  net/nfc/rawsock.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
> index ba5ffd3badd3..c1302b689a98 100644
> --- a/net/nfc/rawsock.c
> +++ b/net/nfc/rawsock.c
> @@ -332,8 +332,11 @@ static int rawsock_create(struct net *net, struct socket *sock,
>  	if ((sock->type != SOCK_SEQPACKET) && (sock->type != SOCK_RAW))
>  		return -ESOCKTNOSUPPORT;
> 
> -	if (sock->type == SOCK_RAW)
> +	if (sock->type == SOCK_RAW){
> +		if (!capable(CAP_NET_RAW))
> +			return -EPERM;
>  		sock->ops = &rawsock_raw_ops;
> +	}

please run checkpatch.pl --strict and fix the issues.

>  	else
>  		sock->ops = &rawsock_ops;
> 
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-06 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06  2:28 [PATCH] nfc: enforce CAP_NET_RAW for raw sockets When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first Qingyu Li
2020-08-06 18:30 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).