diff options
author | Eric Paris <eparis@redhat.com> | 2009-11-06 01:18:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-06 01:18:14 -0500 |
commit | 3f378b684453f2a028eda463ce383370545d9cc9 (patch) | |
tree | dc50d087e137c6d173e25ae10ecd0f10823eca7a | |
parent | 13f18aa05f5abe135f47b6417537ae2b2fedc18c (diff) |
net: pass kern to net_proto_family create function
The generic __sock_create function has a kern argument which allows the
security system to make decisions based on if a socket is being created by
the kernel or by userspace. This patch passes that flag to the
net_proto_family specific create function, so it can do the same thing.
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
37 files changed, 80 insertions, 43 deletions
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c index 28182ed8dea1..fcfe17a19a61 100644 --- a/drivers/isdn/mISDN/socket.c +++ b/drivers/isdn/mISDN/socket.c | |||
@@ -779,7 +779,7 @@ base_sock_create(struct net *net, struct socket *sock, int protocol) | |||
779 | } | 779 | } |
780 | 780 | ||
781 | static int | 781 | static int |
782 | mISDN_sock_create(struct net *net, struct socket *sock, int proto) | 782 | mISDN_sock_create(struct net *net, struct socket *sock, int proto, int kern) |
783 | { | 783 | { |
784 | int err = -EPROTONOSUPPORT; | 784 | int err = -EPROTONOSUPPORT; |
785 | 785 | ||
diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c index c14ee24c05a8..ac806b27c658 100644 --- a/drivers/net/pppox.c +++ b/drivers/net/pppox.c | |||
@@ -104,7 +104,8 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
104 | 104 | ||
105 | EXPORT_SYMBOL(pppox_ioctl); | 105 | EXPORT_SYMBOL(pppox_ioctl); |
106 | 106 | ||
107 | static int pppox_create(struct net *net, struct socket *sock, int protocol) | 107 | static int pppox_create(struct net *net, struct socket *sock, int protocol, |
108 | int kern) | ||
108 | { | 109 | { |
109 | int rc = -EPROTOTYPE; | 110 | int rc = -EPROTOTYPE; |
110 | 111 | ||
diff --git a/include/linux/net.h b/include/linux/net.h index 4da9d571b053..70ee3c310f15 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -204,7 +204,8 @@ struct proto_ops { | |||
204 | 204 | ||
205 | struct net_proto_family { | 205 | struct net_proto_family { |
206 | int family; | 206 | int family; |
207 | int (*create)(struct net *net, struct socket *sock, int protocol); | 207 | int (*create)(struct net *net, struct socket *sock, |
208 | int protocol, int kern); | ||
208 | struct module *owner; | 209 | struct module *owner; |
209 | }; | 210 | }; |
210 | 211 | ||
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index abe38014b7fd..4b0ce2e2b46e 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -1021,7 +1021,8 @@ static struct proto ddp_proto = { | |||
1021 | * Create a socket. Initialise the socket, blank the addresses | 1021 | * Create a socket. Initialise the socket, blank the addresses |
1022 | * set the state. | 1022 | * set the state. |
1023 | */ | 1023 | */ |
1024 | static int atalk_create(struct net *net, struct socket *sock, int protocol) | 1024 | static int atalk_create(struct net *net, struct socket *sock, int protocol, |
1025 | int kern) | ||
1025 | { | 1026 | { |
1026 | struct sock *sk; | 1027 | struct sock *sk; |
1027 | int rc = -ESOCKTNOSUPPORT; | 1028 | int rc = -ESOCKTNOSUPPORT; |
diff --git a/net/atm/pvc.c b/net/atm/pvc.c index a6e1fdbae87f..8d74e62b0d79 100644 --- a/net/atm/pvc.c +++ b/net/atm/pvc.c | |||
@@ -127,7 +127,8 @@ static const struct proto_ops pvc_proto_ops = { | |||
127 | }; | 127 | }; |
128 | 128 | ||
129 | 129 | ||
130 | static int pvc_create(struct net *net, struct socket *sock,int protocol) | 130 | static int pvc_create(struct net *net, struct socket *sock, int protocol, |
131 | int kern) | ||
131 | { | 132 | { |
132 | if (net != &init_net) | 133 | if (net != &init_net) |
133 | return -EAFNOSUPPORT; | 134 | return -EAFNOSUPPORT; |
diff --git a/net/atm/svc.c b/net/atm/svc.c index 819354233318..c7395070ee78 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "signaling.h" | 25 | #include "signaling.h" |
26 | #include "addr.h" | 26 | #include "addr.h" |
27 | 27 | ||
28 | static int svc_create(struct net *net, struct socket *sock,int protocol); | 28 | static int svc_create(struct net *net, struct socket *sock, int protocol, int kern); |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * Note: since all this is still nicely synchronized with the signaling demon, | 31 | * Note: since all this is still nicely synchronized with the signaling demon, |
@@ -330,7 +330,7 @@ static int svc_accept(struct socket *sock,struct socket *newsock,int flags) | |||
330 | 330 | ||
331 | lock_sock(sk); | 331 | lock_sock(sk); |
332 | 332 | ||
333 | error = svc_create(sock_net(sk), newsock,0); | 333 | error = svc_create(sock_net(sk), newsock, 0, 0); |
334 | if (error) | 334 | if (error) |
335 | goto out; | 335 | goto out; |
336 | 336 | ||
@@ -650,7 +650,8 @@ static const struct proto_ops svc_proto_ops = { | |||
650 | }; | 650 | }; |
651 | 651 | ||
652 | 652 | ||
653 | static int svc_create(struct net *net, struct socket *sock,int protocol) | 653 | static int svc_create(struct net *net, struct socket *sock, int protocol, |
654 | int kern) | ||
654 | { | 655 | { |
655 | int error; | 656 | int error; |
656 | 657 | ||
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index f1e998b2796e..d6ddfa4c4471 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -799,7 +799,8 @@ static struct proto ax25_proto = { | |||
799 | .obj_size = sizeof(struct sock), | 799 | .obj_size = sizeof(struct sock), |
800 | }; | 800 | }; |
801 | 801 | ||
802 | static int ax25_create(struct net *net, struct socket *sock, int protocol) | 802 | static int ax25_create(struct net *net, struct socket *sock, int protocol, |
803 | int kern) | ||
803 | { | 804 | { |
804 | struct sock *sk; | 805 | struct sock *sk; |
805 | ax25_cb *ax25; | 806 | ax25_cb *ax25; |
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 399e59c9c6cb..087cc51f5927 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -126,7 +126,8 @@ int bt_sock_unregister(int proto) | |||
126 | } | 126 | } |
127 | EXPORT_SYMBOL(bt_sock_unregister); | 127 | EXPORT_SYMBOL(bt_sock_unregister); |
128 | 128 | ||
129 | static int bt_sock_create(struct net *net, struct socket *sock, int proto) | 129 | static int bt_sock_create(struct net *net, struct socket *sock, int proto, |
130 | int kern) | ||
130 | { | 131 | { |
131 | int err; | 132 | int err; |
132 | 133 | ||
@@ -144,7 +145,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto) | |||
144 | read_lock(&bt_proto_lock); | 145 | read_lock(&bt_proto_lock); |
145 | 146 | ||
146 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { | 147 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { |
147 | err = bt_proto[proto]->create(net, sock, proto); | 148 | err = bt_proto[proto]->create(net, sock, proto, kern); |
148 | bt_sock_reclassify_lock(sock, proto); | 149 | bt_sock_reclassify_lock(sock, proto); |
149 | module_put(bt_proto[proto]->owner); | 150 | module_put(bt_proto[proto]->owner); |
150 | } | 151 | } |
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index 0a2c5460bb48..2ff6ac7b2ed4 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c | |||
@@ -195,7 +195,8 @@ static struct proto bnep_proto = { | |||
195 | .obj_size = sizeof(struct bt_sock) | 195 | .obj_size = sizeof(struct bt_sock) |
196 | }; | 196 | }; |
197 | 197 | ||
198 | static int bnep_sock_create(struct net *net, struct socket *sock, int protocol) | 198 | static int bnep_sock_create(struct net *net, struct socket *sock, int protocol, |
199 | int kern) | ||
199 | { | 200 | { |
200 | struct sock *sk; | 201 | struct sock *sk; |
201 | 202 | ||
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index de7c8040bc56..978cc3a718ad 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c | |||
@@ -190,7 +190,8 @@ static struct proto cmtp_proto = { | |||
190 | .obj_size = sizeof(struct bt_sock) | 190 | .obj_size = sizeof(struct bt_sock) |
191 | }; | 191 | }; |
192 | 192 | ||
193 | static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol) | 193 | static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol, |
194 | int kern) | ||
194 | { | 195 | { |
195 | struct sock *sk; | 196 | struct sock *sk; |
196 | 197 | ||
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index e7395f231989..1ca5c7ca9bd4 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
@@ -621,7 +621,8 @@ static struct proto hci_sk_proto = { | |||
621 | .obj_size = sizeof(struct hci_pinfo) | 621 | .obj_size = sizeof(struct hci_pinfo) |
622 | }; | 622 | }; |
623 | 623 | ||
624 | static int hci_sock_create(struct net *net, struct socket *sock, int protocol) | 624 | static int hci_sock_create(struct net *net, struct socket *sock, int protocol, |
625 | int kern) | ||
625 | { | 626 | { |
626 | struct sock *sk; | 627 | struct sock *sk; |
627 | 628 | ||
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index 4beb6a7a2953..9cfef68b9fec 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c | |||
@@ -241,7 +241,8 @@ static struct proto hidp_proto = { | |||
241 | .obj_size = sizeof(struct bt_sock) | 241 | .obj_size = sizeof(struct bt_sock) |
242 | }; | 242 | }; |
243 | 243 | ||
244 | static int hidp_sock_create(struct net *net, struct socket *sock, int protocol) | 244 | static int hidp_sock_create(struct net *net, struct socket *sock, int protocol, |
245 | int kern) | ||
245 | { | 246 | { |
246 | struct sock *sk; | 247 | struct sock *sk; |
247 | 248 | ||
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index d65101d92ee5..365ae161d702 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -819,7 +819,8 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p | |||
819 | return sk; | 819 | return sk; |
820 | } | 820 | } |
821 | 821 | ||
822 | static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol) | 822 | static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol, |
823 | int kern) | ||
823 | { | 824 | { |
824 | struct sock *sk; | 825 | struct sock *sk; |
825 | 826 | ||
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index d3bfc1b0afb1..4b5968dda673 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -323,7 +323,8 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int | |||
323 | return sk; | 323 | return sk; |
324 | } | 324 | } |
325 | 325 | ||
326 | static int rfcomm_sock_create(struct net *net, struct socket *sock, int protocol) | 326 | static int rfcomm_sock_create(struct net *net, struct socket *sock, |
327 | int protocol, int kern) | ||
327 | { | 328 | { |
328 | struct sock *sk; | 329 | struct sock *sk; |
329 | 330 | ||
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 694a65541b73..dd8f6ec57dce 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -430,7 +430,8 @@ static struct sock *sco_sock_alloc(struct net *net, struct socket *sock, int pro | |||
430 | return sk; | 430 | return sk; |
431 | } | 431 | } |
432 | 432 | ||
433 | static int sco_sock_create(struct net *net, struct socket *sock, int protocol) | 433 | static int sco_sock_create(struct net *net, struct socket *sock, int protocol, |
434 | int kern) | ||
434 | { | 435 | { |
435 | struct sock *sk; | 436 | struct sock *sk; |
436 | 437 | ||
diff --git a/net/can/af_can.c b/net/can/af_can.c index 9c0426dc3184..833bd838edc6 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c | |||
@@ -114,7 +114,8 @@ static void can_sock_destruct(struct sock *sk) | |||
114 | skb_queue_purge(&sk->sk_receive_queue); | 114 | skb_queue_purge(&sk->sk_receive_queue); |
115 | } | 115 | } |
116 | 116 | ||
117 | static int can_create(struct net *net, struct socket *sock, int protocol) | 117 | static int can_create(struct net *net, struct socket *sock, int protocol, |
118 | int kern) | ||
118 | { | 119 | { |
119 | struct sock *sk; | 120 | struct sock *sk; |
120 | struct can_proto *cp; | 121 | struct can_proto *cp; |
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 2e355841ca99..9ade3a6de954 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
@@ -675,7 +675,8 @@ char *dn_addr2asc(__u16 addr, char *buf) | |||
675 | 675 | ||
676 | 676 | ||
677 | 677 | ||
678 | static int dn_create(struct net *net, struct socket *sock, int protocol) | 678 | static int dn_create(struct net *net, struct socket *sock, int protocol, |
679 | int kern) | ||
679 | { | 680 | { |
680 | struct sock *sk; | 681 | struct sock *sk; |
681 | 682 | ||
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 5e9426a11c3e..596679803de5 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -605,7 +605,8 @@ static struct proto econet_proto = { | |||
605 | * Create an Econet socket | 605 | * Create an Econet socket |
606 | */ | 606 | */ |
607 | 607 | ||
608 | static int econet_create(struct net *net, struct socket *sock, int protocol) | 608 | static int econet_create(struct net *net, struct socket *sock, int protocol, |
609 | int kern) | ||
609 | { | 610 | { |
610 | struct sock *sk; | 611 | struct sock *sk; |
611 | struct econet_sock *eo; | 612 | struct econet_sock *eo; |
diff --git a/net/ieee802154/af_ieee802154.c b/net/ieee802154/af_ieee802154.c index 309348fba72b..de6e34d2a7f8 100644 --- a/net/ieee802154/af_ieee802154.c +++ b/net/ieee802154/af_ieee802154.c | |||
@@ -234,7 +234,7 @@ static const struct proto_ops ieee802154_dgram_ops = { | |||
234 | * set the state. | 234 | * set the state. |
235 | */ | 235 | */ |
236 | static int ieee802154_create(struct net *net, struct socket *sock, | 236 | static int ieee802154_create(struct net *net, struct socket *sock, |
237 | int protocol) | 237 | int protocol, int kern) |
238 | { | 238 | { |
239 | struct sock *sk; | 239 | struct sock *sk; |
240 | int rc; | 240 | int rc; |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 180ec4c94919..5c7e42c02afb 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -262,7 +262,8 @@ static inline int inet_netns_ok(struct net *net, int protocol) | |||
262 | * Create an inet socket. | 262 | * Create an inet socket. |
263 | */ | 263 | */ |
264 | 264 | ||
265 | static int inet_create(struct net *net, struct socket *sock, int protocol) | 265 | static int inet_create(struct net *net, struct socket *sock, int protocol, |
266 | int kern) | ||
266 | { | 267 | { |
267 | struct sock *sk; | 268 | struct sock *sk; |
268 | struct inet_protosw *answer; | 269 | struct inet_protosw *answer; |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 1b3889356599..45ed5e05ab32 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -95,7 +95,8 @@ static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk) | |||
95 | return (struct ipv6_pinfo *)(((u8 *)sk) + offset); | 95 | return (struct ipv6_pinfo *)(((u8 *)sk) + offset); |
96 | } | 96 | } |
97 | 97 | ||
98 | static int inet6_create(struct net *net, struct socket *sock, int protocol) | 98 | static int inet6_create(struct net *net, struct socket *sock, int protocol, |
99 | int kern) | ||
99 | { | 100 | { |
100 | struct inet_sock *inet; | 101 | struct inet_sock *inet; |
101 | struct ipv6_pinfo *np; | 102 | struct ipv6_pinfo *np; |
diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 6481ee4bdf72..96d193a24415 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c | |||
@@ -1352,7 +1352,8 @@ static struct proto ipx_proto = { | |||
1352 | .obj_size = sizeof(struct ipx_sock), | 1352 | .obj_size = sizeof(struct ipx_sock), |
1353 | }; | 1353 | }; |
1354 | 1354 | ||
1355 | static int ipx_create(struct net *net, struct socket *sock, int protocol) | 1355 | static int ipx_create(struct net *net, struct socket *sock, int protocol, |
1356 | int kern) | ||
1356 | { | 1357 | { |
1357 | int rc = -ESOCKTNOSUPPORT; | 1358 | int rc = -ESOCKTNOSUPPORT; |
1358 | struct sock *sk; | 1359 | struct sock *sk; |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 9429e4002bca..e73a0016c0aa 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -61,7 +61,7 @@ | |||
61 | 61 | ||
62 | #include <net/irda/af_irda.h> | 62 | #include <net/irda/af_irda.h> |
63 | 63 | ||
64 | static int irda_create(struct net *net, struct socket *sock, int protocol); | 64 | static int irda_create(struct net *net, struct socket *sock, int protocol, int kern); |
65 | 65 | ||
66 | static const struct proto_ops irda_stream_ops; | 66 | static const struct proto_ops irda_stream_ops; |
67 | static const struct proto_ops irda_seqpacket_ops; | 67 | static const struct proto_ops irda_seqpacket_ops; |
@@ -839,7 +839,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | |||
839 | 839 | ||
840 | IRDA_DEBUG(2, "%s()\n", __func__); | 840 | IRDA_DEBUG(2, "%s()\n", __func__); |
841 | 841 | ||
842 | err = irda_create(sock_net(sk), newsock, sk->sk_protocol); | 842 | err = irda_create(sock_net(sk), newsock, sk->sk_protocol, 0); |
843 | if (err) | 843 | if (err) |
844 | return err; | 844 | return err; |
845 | 845 | ||
@@ -1062,7 +1062,8 @@ static struct proto irda_proto = { | |||
1062 | * Create IrDA socket | 1062 | * Create IrDA socket |
1063 | * | 1063 | * |
1064 | */ | 1064 | */ |
1065 | static int irda_create(struct net *net, struct socket *sock, int protocol) | 1065 | static int irda_create(struct net *net, struct socket *sock, int protocol, |
1066 | int kern) | ||
1066 | { | 1067 | { |
1067 | struct sock *sk; | 1068 | struct sock *sk; |
1068 | struct irda_sock *self; | 1069 | struct irda_sock *self; |
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 3aebabb158a8..1e428863574f 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -481,7 +481,8 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio) | |||
481 | } | 481 | } |
482 | 482 | ||
483 | /* Create an IUCV socket */ | 483 | /* Create an IUCV socket */ |
484 | static int iucv_sock_create(struct net *net, struct socket *sock, int protocol) | 484 | static int iucv_sock_create(struct net *net, struct socket *sock, int protocol, |
485 | int kern) | ||
485 | { | 486 | { |
486 | struct sock *sk; | 487 | struct sock *sk; |
487 | 488 | ||
diff --git a/net/key/af_key.c b/net/key/af_key.c index 472f6594184a..86b2c22d0918 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -177,7 +177,8 @@ static struct proto key_proto = { | |||
177 | .obj_size = sizeof(struct pfkey_sock), | 177 | .obj_size = sizeof(struct pfkey_sock), |
178 | }; | 178 | }; |
179 | 179 | ||
180 | static int pfkey_create(struct net *net, struct socket *sock, int protocol) | 180 | static int pfkey_create(struct net *net, struct socket *sock, int protocol, |
181 | int kern) | ||
181 | { | 182 | { |
182 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); | 183 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
183 | struct sock *sk; | 184 | struct sock *sk; |
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 4866b4fb0c27..5266c286b260 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c | |||
@@ -140,14 +140,17 @@ static struct proto llc_proto = { | |||
140 | 140 | ||
141 | /** | 141 | /** |
142 | * llc_ui_create - alloc and init a new llc_ui socket | 142 | * llc_ui_create - alloc and init a new llc_ui socket |
143 | * @net: network namespace (must be default network) | ||
143 | * @sock: Socket to initialize and attach allocated sk to. | 144 | * @sock: Socket to initialize and attach allocated sk to. |
144 | * @protocol: Unused. | 145 | * @protocol: Unused. |
146 | * @kern: on behalf of kernel or userspace | ||
145 | * | 147 | * |
146 | * Allocate and initialize a new llc_ui socket, validate the user wants a | 148 | * Allocate and initialize a new llc_ui socket, validate the user wants a |
147 | * socket type we have available. | 149 | * socket type we have available. |
148 | * Returns 0 upon success, negative upon failure. | 150 | * Returns 0 upon success, negative upon failure. |
149 | */ | 151 | */ |
150 | static int llc_ui_create(struct net *net, struct socket *sock, int protocol) | 152 | static int llc_ui_create(struct net *net, struct socket *sock, int protocol, |
153 | int kern) | ||
151 | { | 154 | { |
152 | struct sock *sk; | 155 | struct sock *sk; |
153 | int rc = -ESOCKTNOSUPPORT; | 156 | int rc = -ESOCKTNOSUPPORT; |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 0cd2d8829313..aea805c98da3 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -428,7 +428,8 @@ static int __netlink_create(struct net *net, struct socket *sock, | |||
428 | return 0; | 428 | return 0; |
429 | } | 429 | } |
430 | 430 | ||
431 | static int netlink_create(struct net *net, struct socket *sock, int protocol) | 431 | static int netlink_create(struct net *net, struct socket *sock, int protocol, |
432 | int kern) | ||
432 | { | 433 | { |
433 | struct module *module = NULL; | 434 | struct module *module = NULL; |
434 | struct mutex *cb_mutex; | 435 | struct mutex *cb_mutex; |
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 281fa597cae5..4bdd5697f63b 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
@@ -425,7 +425,8 @@ static struct proto nr_proto = { | |||
425 | .obj_size = sizeof(struct nr_sock), | 425 | .obj_size = sizeof(struct nr_sock), |
426 | }; | 426 | }; |
427 | 427 | ||
428 | static int nr_create(struct net *net, struct socket *sock, int protocol) | 428 | static int nr_create(struct net *net, struct socket *sock, int protocol, |
429 | int kern) | ||
429 | { | 430 | { |
430 | struct sock *sk; | 431 | struct sock *sk; |
431 | struct nr_sock *nr; | 432 | struct nr_sock *nr; |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 91d246d34780..3304caa65347 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -1344,7 +1344,8 @@ static struct proto packet_proto = { | |||
1344 | * Create a packet of type SOCK_PACKET. | 1344 | * Create a packet of type SOCK_PACKET. |
1345 | */ | 1345 | */ |
1346 | 1346 | ||
1347 | static int packet_create(struct net *net, struct socket *sock, int protocol) | 1347 | static int packet_create(struct net *net, struct socket *sock, int protocol, |
1348 | int kern) | ||
1348 | { | 1349 | { |
1349 | struct sock *sk; | 1350 | struct sock *sk; |
1350 | struct packet_sock *po; | 1351 | struct packet_sock *po; |
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index 66737aa995ea..3bd1be6b26f0 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c | |||
@@ -60,7 +60,8 @@ static inline void phonet_proto_put(struct phonet_protocol *pp) | |||
60 | 60 | ||
61 | /* protocol family functions */ | 61 | /* protocol family functions */ |
62 | 62 | ||
63 | static int pn_socket_create(struct net *net, struct socket *sock, int protocol) | 63 | static int pn_socket_create(struct net *net, struct socket *sock, int protocol, |
64 | int kern) | ||
64 | { | 65 | { |
65 | struct sock *sk; | 66 | struct sock *sk; |
66 | struct pn_sock *pn; | 67 | struct pn_sock *pn; |
diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c index 2b978dc6e75d..e25d8d5ce8df 100644 --- a/net/rds/af_rds.c +++ b/net/rds/af_rds.c | |||
@@ -410,7 +410,8 @@ static int __rds_create(struct socket *sock, struct sock *sk, int protocol) | |||
410 | return 0; | 410 | return 0; |
411 | } | 411 | } |
412 | 412 | ||
413 | static int rds_create(struct net *net, struct socket *sock, int protocol) | 413 | static int rds_create(struct net *net, struct socket *sock, int protocol, |
414 | int kern) | ||
414 | { | 415 | { |
415 | struct sock *sk; | 416 | struct sock *sk; |
416 | 417 | ||
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index c17734c2ce89..4de4287fec37 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -512,7 +512,8 @@ static struct proto rose_proto = { | |||
512 | .obj_size = sizeof(struct rose_sock), | 512 | .obj_size = sizeof(struct rose_sock), |
513 | }; | 513 | }; |
514 | 514 | ||
515 | static int rose_create(struct net *net, struct socket *sock, int protocol) | 515 | static int rose_create(struct net *net, struct socket *sock, int protocol, |
516 | int kern) | ||
516 | { | 517 | { |
517 | struct sock *sk; | 518 | struct sock *sk; |
518 | struct rose_sock *rose; | 519 | struct rose_sock *rose; |
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c index 6817c9781ef3..f978d02a248a 100644 --- a/net/rxrpc/af_rxrpc.c +++ b/net/rxrpc/af_rxrpc.c | |||
@@ -608,7 +608,8 @@ static unsigned int rxrpc_poll(struct file *file, struct socket *sock, | |||
608 | /* | 608 | /* |
609 | * create an RxRPC socket | 609 | * create an RxRPC socket |
610 | */ | 610 | */ |
611 | static int rxrpc_create(struct net *net, struct socket *sock, int protocol) | 611 | static int rxrpc_create(struct net *net, struct socket *sock, int protocol, |
612 | int kern) | ||
612 | { | 613 | { |
613 | struct rxrpc_sock *rx; | 614 | struct rxrpc_sock *rx; |
614 | struct sock *sk; | 615 | struct sock *sk; |
diff --git a/net/socket.c b/net/socket.c index 9dff31c9b799..4f3e0f0c156b 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -1252,7 +1252,7 @@ static int __sock_create(struct net *net, int family, int type, int protocol, | |||
1252 | /* Now protected by module ref count */ | 1252 | /* Now protected by module ref count */ |
1253 | rcu_read_unlock(); | 1253 | rcu_read_unlock(); |
1254 | 1254 | ||
1255 | err = pf->create(net, sock, protocol); | 1255 | err = pf->create(net, sock, protocol, kern); |
1256 | if (err < 0) | 1256 | if (err < 0) |
1257 | goto out_module_put; | 1257 | goto out_module_put; |
1258 | 1258 | ||
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e6d9abf7440e..d00c2119faf3 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -177,6 +177,7 @@ static void reject_rx_queue(struct sock *sk) | |||
177 | * @net: network namespace (must be default network) | 177 | * @net: network namespace (must be default network) |
178 | * @sock: pre-allocated socket structure | 178 | * @sock: pre-allocated socket structure |
179 | * @protocol: protocol indicator (must be 0) | 179 | * @protocol: protocol indicator (must be 0) |
180 | * @kern: caused by kernel or by userspace? | ||
180 | * | 181 | * |
181 | * This routine creates additional data structures used by the TIPC socket, | 182 | * This routine creates additional data structures used by the TIPC socket, |
182 | * initializes them, and links them together. | 183 | * initializes them, and links them together. |
@@ -184,7 +185,8 @@ static void reject_rx_queue(struct sock *sk) | |||
184 | * Returns 0 on success, errno otherwise | 185 | * Returns 0 on success, errno otherwise |
185 | */ | 186 | */ |
186 | 187 | ||
187 | static int tipc_create(struct net *net, struct socket *sock, int protocol) | 188 | static int tipc_create(struct net *net, struct socket *sock, int protocol, |
189 | int kern) | ||
188 | { | 190 | { |
189 | const struct proto_ops *ops; | 191 | const struct proto_ops *ops; |
190 | socket_state state; | 192 | socket_state state; |
@@ -1528,7 +1530,7 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) | |||
1528 | 1530 | ||
1529 | buf = skb_peek(&sk->sk_receive_queue); | 1531 | buf = skb_peek(&sk->sk_receive_queue); |
1530 | 1532 | ||
1531 | res = tipc_create(sock_net(sock->sk), new_sock, 0); | 1533 | res = tipc_create(sock_net(sock->sk), new_sock, 0, 0); |
1532 | if (!res) { | 1534 | if (!res) { |
1533 | struct sock *new_sk = new_sock->sk; | 1535 | struct sock *new_sk = new_sock->sk; |
1534 | struct tipc_sock *new_tsock = tipc_sk(new_sk); | 1536 | struct tipc_sock *new_tsock = tipc_sk(new_sk); |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 3291902f0b88..178d3af2a605 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -621,7 +621,8 @@ out: | |||
621 | return sk; | 621 | return sk; |
622 | } | 622 | } |
623 | 623 | ||
624 | static int unix_create(struct net *net, struct socket *sock, int protocol) | 624 | static int unix_create(struct net *net, struct socket *sock, int protocol, |
625 | int kern) | ||
625 | { | 626 | { |
626 | if (protocol && protocol != PF_UNIX) | 627 | if (protocol && protocol != PF_UNIX) |
627 | return -EPROTONOSUPPORT; | 628 | return -EPROTONOSUPPORT; |
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index e19d811788a5..38e235f61e27 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -501,7 +501,8 @@ out: | |||
501 | return sk; | 501 | return sk; |
502 | } | 502 | } |
503 | 503 | ||
504 | static int x25_create(struct net *net, struct socket *sock, int protocol) | 504 | static int x25_create(struct net *net, struct socket *sock, int protocol, |
505 | int kern) | ||
505 | { | 506 | { |
506 | struct sock *sk; | 507 | struct sock *sk; |
507 | struct x25_sock *x25; | 508 | struct x25_sock *x25; |