Subject: [PATCH 3/5] ax25: enforce CAP_NET_RAW for raw sockets

From: Greg Kroah-Hartman <[email-masked]>
Date: Fri, 20 Sep 2019 09:35:47 +0200

From: Ori Nimron <[email-masked]>

When creating a raw AF_AX25 socket, CAP_NET_RAW needs to be checked
first.

Signed-off-by: Ori Nimron <[email-masked]>
Signed-off-by: Greg Kroah-Hartman <[email-masked]>
---
 net/ax25/af_ax25.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index ca5207767dc2..bb222b882b67 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -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;
-- 
2.23.0