Raw socket cleanups
Subsystems (4)
PATCH 1/5 mISDN: enforce CAP_NET_RAW for raw sockets
In reply to Greg Kroah-HartmanFrom: Ori Nimron <[email protected]>
When creating a raw AF_ISDN socket, CAP_NET_RAW needs to be checked first.
--- drivers/isdn/mISDN/socket.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/isdn/mISDN/socket.c +2 -0
@@ -754,6 +754,8 @@ base_sock_create(struct net *net, struct socket *sock, int protocol, int kern)if (sock->type !=SOCK_RAW )return -ESOCKTNOSUPPORT ; +if (!capable (CAP_NET_RAW )) +return -EPERM ; sk =sk_alloc (net,PF_ISDN ,GFP_KERNEL , &mISDN_proto, kern);if (!sk)
Signature · 1 line
2.23.0
cover Raw socket cleanups
Ori Nimron pointed out that there are a number of places in the kernel where you can create a raw socket, without having to have the CAP_NET_RAW permission.
To resolve this, here's a short patch series to test these odd and old protocols for this permission before allowing the creation to succeed
All patches are currently against the net tree.
thanks,
greg k-h
Ori Nimron (5):
mISDN: enforce CAP_NET_RAW for raw sockets
appletalk: enforce CAP_NET_RAW for raw sockets
ax25: enforce CAP_NET_RAW for raw sockets
ieee802154: enforce CAP_NET_RAW for raw sockets
nfc: enforce CAP_NET_RAW for raw sockets
drivers/isdn/mISDN/socket.c | 2 ++ net/appletalk/ddp.c | 5 +++++ net/ax25/af_ax25.c | 2 ++ net/ieee802154/socket.c | 3 +++ net/nfc/llcp_sock.c | 7 +++++-- 5 files changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.23.0
PATCH 2/5 appletalk: enforce CAP_NET_RAW for raw sockets
From: Ori Nimron <[email protected]>
When creating a raw AF_APPLETALK socket, CAP_NET_RAW needs to be checked first.
--- net/appletalk/ddp.c | 5 +++++ 1 file changed, 5 insertions(+)
net/appletalk/ddp.c +5 -0
@@ -1023,6 +1023,11 @@ static int atalk_create(struct net *net, struct socket *sock, int protocol,*/ if (sock->type !=SOCK_RAW && sock->type !=SOCK_DGRAM ) goto out; + + rc = -EPERM ; +if (sock->type ==SOCK_RAW && !kern && !capable (CAP_NET_RAW )) + goto out; + rc = -ENOMEM ; sk =sk_alloc (net,PF_APPLETALK ,GFP_KERNEL , &ddp_proto, kern);if (!sk)
Signature · 1 line
2.23.0
PATCH 4/5 ieee802154: enforce CAP_NET_RAW for raw sockets
In reply to Greg Kroah-HartmanFrom: Ori Nimron <[email protected]>
When creating a raw AF_IEEE802154 socket, CAP_NET_RAW needs to be checked first.
--- net/ieee802154/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/ieee802154/socket.c +3 -0
@@ -1008,6 +1008,9 @@ static int ieee802154_create(struct net *net, struct socket *sock,switch (sock->type) {case SOCK_RAW : + rc = -EPERM ; +if (!capable (CAP_NET_RAW )) + goto out; proto = &ieee802154_raw_prot; ops = &ieee802154_raw_ops;break ;
Signature · 1 line
2.23.0
PATCH 5/5 nfc: enforce CAP_NET_RAW for raw sockets
In reply to Greg Kroah-HartmanFrom: Ori Nimron <[email protected]>
When creating a raw AF_NFC socket, CAP_NET_RAW needs to be checked first.
--- net/nfc/llcp_sock.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/nfc/llcp_sock.c +5 -2
@@ -1004,10 +1004,13 @@ static int llcp_sock_create(struct net *net, struct socket *sock, 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 = &llcp_rawsock_ops; -else + }else { sock->ops = &llcp_sock_ops; + } sk =nfc_llcp_sock_alloc (sock, sock->type,GFP_ATOMIC , kern);if (sk ==NULL )
Signature · 1 line
2.23.0
PATCH 3/5 ax25: enforce CAP_NET_RAW for raw sockets
In reply to Greg Kroah-HartmanFrom: Ori Nimron <[email protected]>
When creating a raw AF_AX25 socket, CAP_NET_RAW needs to be checked first.
--- net/ax25/af_ax25.c | 2 ++ 1 file changed, 2 insertions(+)
net/ax25/af_ax25.c +2 -0
@@ -855,6 +855,8 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,break ;case SOCK_RAW : +if (!capable (CAP_NET_RAW )) +return -EPERM ;break ;default :return -ESOCKTNOSUPPORT ;
Signature · 1 line
2.23.0
Re: [PATCH 4/5] ieee802154: enforce CAP_NET_RAW for raw sockets
In reply to Greg Kroah-HartmanHello.
Quoted 17 lines · Greg Kroah-Hartman
From: Ori Nimron <[email protected]>
When creating a raw
AF_IEEE802154socket,CAP_NET_RAWneeds to be checked first.Signed-off-by Ori Nimron <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- net/ieee802154/socket.c | 3 +++ 1 file changed, 3 insertions(+)net/ieee802154/socket.c +0
-0
net/ieee802154/socket.c static int ieee802154_create(struct net *net, struct socket *sock, · line 1016
Quoted 9 lines
net/ieee802154/socket.c +3
-0@@ -1008,6 +1008,9 @@ static int ieee802154_create(struct net *net, struct socket *sock,switch (sock->type) {case SOCK_RAW : + rc = -EPERM ; +if (!capable (CAP_NET_RAW )) + goto out; proto = &ieee802154_raw_prot; ops = &ieee802154_raw_ops;break ;
I assume this will go as a whole series into net. If you want me to pick it up into my tree directly let me know.
regards
Stefan Schmidt
Re: [PATCH 4/5] ieee802154: enforce CAP_NET_RAW for raw sockets
Quoted 33 lines · Stefan Schmidt
Hello.
Quoted 17 lines · Greg Kroah-Hartman
From: Ori Nimron <[email protected]>
When creating a raw
AF_IEEE802154socket,CAP_NET_RAWneeds to be checked first.Signed-off-by Ori Nimron <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- net/ieee802154/socket.c | 3 +++ 1 file changed, 3 insertions(+)net/ieee802154/socket.c +0
-0net/ieee802154/socket.c static int ieee802154_create(struct net *net, struct socket *sock, · line 1016
Quoted 9 lines
net/ieee802154/socket.c +3
-0@@ -1008,6 +1008,9 @@ static int ieee802154_create(struct net *net, struct socket *sock,switch (sock->type) {case SOCK_RAW : + rc = -EPERM ; +if (!capable (CAP_NET_RAW )) + goto out; proto = &ieee802154_raw_prot; ops = &ieee802154_raw_ops;break ;I assume this will go as a whole series into net. If you want me to pick it up into my tree directly let me know.
Quoted 1 line
Acked-by Stefan Schmidt <[email protected]>
That's up to the networking maintainer, if he does not suck it in, I'll resend and ask you to take it.
thanks,
greg k-h
David Miller
maintainerFrom: Greg Kroah-Hartman <[email protected]>
Date: Fri, 20 Sep 2019 09:35:44 +0200
Quoted 8 lines
Ori Nimron pointed out that there are a number of places in the kernel where you can create a raw socket, without having to have the
CAP_NET_RAWpermission.To resolve this, here's a short patch series to test these odd and old protocols for this permission before allowing the creation to succeed
All patches are currently against the net tree.
Applied and queued up for -stable.