diff options
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 56502292f24c..766b5faaed21 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -977,13 +977,16 @@ static struct proto packet_proto = { | |||
977 | * Create a packet of type SOCK_PACKET. | 977 | * Create a packet of type SOCK_PACKET. |
978 | */ | 978 | */ |
979 | 979 | ||
980 | static int packet_create(struct socket *sock, int protocol) | 980 | static int packet_create(struct net *net, struct socket *sock, int protocol) |
981 | { | 981 | { |
982 | struct sock *sk; | 982 | struct sock *sk; |
983 | struct packet_sock *po; | 983 | struct packet_sock *po; |
984 | __be16 proto = (__force __be16)protocol; /* weird, but documented */ | 984 | __be16 proto = (__force __be16)protocol; /* weird, but documented */ |
985 | int err; | 985 | int err; |
986 | 986 | ||
987 | if (net != &init_net) | ||
988 | return -EAFNOSUPPORT; | ||
989 | |||
987 | if (!capable(CAP_NET_RAW)) | 990 | if (!capable(CAP_NET_RAW)) |
988 | return -EPERM; | 991 | return -EPERM; |
989 | if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW && | 992 | if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW && |
@@ -993,7 +996,7 @@ static int packet_create(struct socket *sock, int protocol) | |||
993 | sock->state = SS_UNCONNECTED; | 996 | sock->state = SS_UNCONNECTED; |
994 | 997 | ||
995 | err = -ENOBUFS; | 998 | err = -ENOBUFS; |
996 | sk = sk_alloc(PF_PACKET, GFP_KERNEL, &packet_proto, 1); | 999 | sk = sk_alloc(net, PF_PACKET, GFP_KERNEL, &packet_proto, 1); |
997 | if (sk == NULL) | 1000 | if (sk == NULL) |
998 | goto out; | 1001 | goto out; |
999 | 1002 | ||