diff options
38 files changed, 142 insertions, 108 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index f5e18c2a4852..690deca17c35 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c | |||
@@ -266,7 +266,7 @@ unlock: | |||
266 | return err; | 266 | return err; |
267 | } | 267 | } |
268 | 268 | ||
269 | int af_alg_accept(struct sock *sk, struct socket *newsock) | 269 | int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern) |
270 | { | 270 | { |
271 | struct alg_sock *ask = alg_sk(sk); | 271 | struct alg_sock *ask = alg_sk(sk); |
272 | const struct af_alg_type *type; | 272 | const struct af_alg_type *type; |
@@ -281,7 +281,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock) | |||
281 | if (!type) | 281 | if (!type) |
282 | goto unlock; | 282 | goto unlock; |
283 | 283 | ||
284 | sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, 0); | 284 | sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, kern); |
285 | err = -ENOMEM; | 285 | err = -ENOMEM; |
286 | if (!sk2) | 286 | if (!sk2) |
287 | goto unlock; | 287 | goto unlock; |
@@ -323,9 +323,10 @@ unlock: | |||
323 | } | 323 | } |
324 | EXPORT_SYMBOL_GPL(af_alg_accept); | 324 | EXPORT_SYMBOL_GPL(af_alg_accept); |
325 | 325 | ||
326 | static int alg_accept(struct socket *sock, struct socket *newsock, int flags) | 326 | static int alg_accept(struct socket *sock, struct socket *newsock, int flags, |
327 | bool kern) | ||
327 | { | 328 | { |
328 | return af_alg_accept(sock->sk, newsock); | 329 | return af_alg_accept(sock->sk, newsock, kern); |
329 | } | 330 | } |
330 | 331 | ||
331 | static const struct proto_ops alg_proto_ops = { | 332 | static const struct proto_ops alg_proto_ops = { |
diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 54fc90e8339c..5e92bd275ef3 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c | |||
@@ -239,7 +239,8 @@ unlock: | |||
239 | return err ?: len; | 239 | return err ?: len; |
240 | } | 240 | } |
241 | 241 | ||
242 | static int hash_accept(struct socket *sock, struct socket *newsock, int flags) | 242 | static int hash_accept(struct socket *sock, struct socket *newsock, int flags, |
243 | bool kern) | ||
243 | { | 244 | { |
244 | struct sock *sk = sock->sk; | 245 | struct sock *sk = sock->sk; |
245 | struct alg_sock *ask = alg_sk(sk); | 246 | struct alg_sock *ask = alg_sk(sk); |
@@ -260,7 +261,7 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags) | |||
260 | if (err) | 261 | if (err) |
261 | return err; | 262 | return err; |
262 | 263 | ||
263 | err = af_alg_accept(ask->parent, newsock); | 264 | err = af_alg_accept(ask->parent, newsock, kern); |
264 | if (err) | 265 | if (err) |
265 | return err; | 266 | return err; |
266 | 267 | ||
@@ -378,7 +379,7 @@ static int hash_recvmsg_nokey(struct socket *sock, struct msghdr *msg, | |||
378 | } | 379 | } |
379 | 380 | ||
380 | static int hash_accept_nokey(struct socket *sock, struct socket *newsock, | 381 | static int hash_accept_nokey(struct socket *sock, struct socket *newsock, |
381 | int flags) | 382 | int flags, bool kern) |
382 | { | 383 | { |
383 | int err; | 384 | int err; |
384 | 385 | ||
@@ -386,7 +387,7 @@ static int hash_accept_nokey(struct socket *sock, struct socket *newsock, | |||
386 | if (err) | 387 | if (err) |
387 | return err; | 388 | return err; |
388 | 389 | ||
389 | return hash_accept(sock, newsock, flags); | 390 | return hash_accept(sock, newsock, flags, kern); |
390 | } | 391 | } |
391 | 392 | ||
392 | static struct proto_ops algif_hash_ops_nokey = { | 393 | static struct proto_ops algif_hash_ops_nokey = { |
diff --git a/drivers/staging/lustre/lnet/lnet/lib-socket.c b/drivers/staging/lustre/lnet/lnet/lib-socket.c index b7b87ecefcdf..9fca8d225ee0 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-socket.c +++ b/drivers/staging/lustre/lnet/lnet/lib-socket.c | |||
@@ -532,7 +532,7 @@ lnet_sock_accept(struct socket **newsockp, struct socket *sock) | |||
532 | 532 | ||
533 | newsock->ops = sock->ops; | 533 | newsock->ops = sock->ops; |
534 | 534 | ||
535 | rc = sock->ops->accept(sock, newsock, O_NONBLOCK); | 535 | rc = sock->ops->accept(sock, newsock, O_NONBLOCK, false); |
536 | if (rc == -EAGAIN) { | 536 | if (rc == -EAGAIN) { |
537 | /* Nothing ready, so wait for activity */ | 537 | /* Nothing ready, so wait for activity */ |
538 | init_waitqueue_entry(&wait, current); | 538 | init_waitqueue_entry(&wait, current); |
@@ -540,7 +540,7 @@ lnet_sock_accept(struct socket **newsockp, struct socket *sock) | |||
540 | set_current_state(TASK_INTERRUPTIBLE); | 540 | set_current_state(TASK_INTERRUPTIBLE); |
541 | schedule(); | 541 | schedule(); |
542 | remove_wait_queue(sk_sleep(sock->sk), &wait); | 542 | remove_wait_queue(sk_sleep(sock->sk), &wait); |
543 | rc = sock->ops->accept(sock, newsock, O_NONBLOCK); | 543 | rc = sock->ops->accept(sock, newsock, O_NONBLOCK, false); |
544 | } | 544 | } |
545 | 545 | ||
546 | if (rc) | 546 | if (rc) |
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 7d398d300e97..9382db998ec9 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c | |||
@@ -743,7 +743,7 @@ static int tcp_accept_from_sock(struct connection *con) | |||
743 | newsock->type = con->sock->type; | 743 | newsock->type = con->sock->type; |
744 | newsock->ops = con->sock->ops; | 744 | newsock->ops = con->sock->ops; |
745 | 745 | ||
746 | result = con->sock->ops->accept(con->sock, newsock, O_NONBLOCK); | 746 | result = con->sock->ops->accept(con->sock, newsock, O_NONBLOCK, true); |
747 | if (result < 0) | 747 | if (result < 0) |
748 | goto accept_err; | 748 | goto accept_err; |
749 | 749 | ||
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 4348027384f5..d0ab7e56d0b4 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
@@ -1863,7 +1863,7 @@ static int o2net_accept_one(struct socket *sock, int *more) | |||
1863 | 1863 | ||
1864 | new_sock->type = sock->type; | 1864 | new_sock->type = sock->type; |
1865 | new_sock->ops = sock->ops; | 1865 | new_sock->ops = sock->ops; |
1866 | ret = sock->ops->accept(sock, new_sock, O_NONBLOCK); | 1866 | ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, false); |
1867 | if (ret < 0) | 1867 | if (ret < 0) |
1868 | goto out; | 1868 | goto out; |
1869 | 1869 | ||
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h index a2bfd7843f18..e2b9c6fe2714 100644 --- a/include/crypto/if_alg.h +++ b/include/crypto/if_alg.h | |||
@@ -73,7 +73,7 @@ int af_alg_unregister_type(const struct af_alg_type *type); | |||
73 | 73 | ||
74 | int af_alg_release(struct socket *sock); | 74 | int af_alg_release(struct socket *sock); |
75 | void af_alg_release_parent(struct sock *sk); | 75 | void af_alg_release_parent(struct sock *sk); |
76 | int af_alg_accept(struct sock *sk, struct socket *newsock); | 76 | int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern); |
77 | 77 | ||
78 | int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len); | 78 | int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len); |
79 | void af_alg_free_sg(struct af_alg_sgl *sgl); | 79 | void af_alg_free_sg(struct af_alg_sgl *sgl); |
diff --git a/include/linux/net.h b/include/linux/net.h index cd0c8bd0a1de..0620f5e18c96 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -146,7 +146,7 @@ struct proto_ops { | |||
146 | int (*socketpair)(struct socket *sock1, | 146 | int (*socketpair)(struct socket *sock1, |
147 | struct socket *sock2); | 147 | struct socket *sock2); |
148 | int (*accept) (struct socket *sock, | 148 | int (*accept) (struct socket *sock, |
149 | struct socket *newsock, int flags); | 149 | struct socket *newsock, int flags, bool kern); |
150 | int (*getname) (struct socket *sock, | 150 | int (*getname) (struct socket *sock, |
151 | struct sockaddr *addr, | 151 | struct sockaddr *addr, |
152 | int *sockaddr_len, int peer); | 152 | int *sockaddr_len, int peer); |
diff --git a/include/net/inet_common.h b/include/net/inet_common.h index b7952d55b9c0..f39ae697347f 100644 --- a/include/net/inet_common.h +++ b/include/net/inet_common.h | |||
@@ -20,7 +20,8 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr, | |||
20 | int addr_len, int flags, int is_sendmsg); | 20 | int addr_len, int flags, int is_sendmsg); |
21 | int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, | 21 | int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, |
22 | int addr_len, int flags); | 22 | int addr_len, int flags); |
23 | int inet_accept(struct socket *sock, struct socket *newsock, int flags); | 23 | int inet_accept(struct socket *sock, struct socket *newsock, int flags, |
24 | bool kern); | ||
24 | int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size); | 25 | int inet_sendmsg(struct socket *sock, struct msghdr *msg, size_t size); |
25 | ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset, | 26 | ssize_t inet_sendpage(struct socket *sock, struct page *page, int offset, |
26 | size_t size, int flags); | 27 | size_t size, int flags); |
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 826f198374f8..c7a577976bec 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -258,7 +258,7 @@ inet_csk_rto_backoff(const struct inet_connection_sock *icsk, | |||
258 | return (unsigned long)min_t(u64, when, max_when); | 258 | return (unsigned long)min_t(u64, when, max_when); |
259 | } | 259 | } |
260 | 260 | ||
261 | struct sock *inet_csk_accept(struct sock *sk, int flags, int *err); | 261 | struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern); |
262 | 262 | ||
263 | int inet_csk_get_port(struct sock *sk, unsigned short snum); | 263 | int inet_csk_get_port(struct sock *sk, unsigned short snum); |
264 | 264 | ||
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index a244db5e5ff7..07a0b128625a 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -476,7 +476,8 @@ struct sctp_pf { | |||
476 | int (*send_verify) (struct sctp_sock *, union sctp_addr *); | 476 | int (*send_verify) (struct sctp_sock *, union sctp_addr *); |
477 | int (*supported_addrs)(const struct sctp_sock *, __be16 *); | 477 | int (*supported_addrs)(const struct sctp_sock *, __be16 *); |
478 | struct sock *(*create_accept_sk) (struct sock *sk, | 478 | struct sock *(*create_accept_sk) (struct sock *sk, |
479 | struct sctp_association *asoc); | 479 | struct sctp_association *asoc, |
480 | bool kern); | ||
480 | int (*addr_to_user)(struct sctp_sock *sk, union sctp_addr *addr); | 481 | int (*addr_to_user)(struct sctp_sock *sk, union sctp_addr *addr); |
481 | void (*to_sk_saddr)(union sctp_addr *, struct sock *sk); | 482 | void (*to_sk_saddr)(union sctp_addr *, struct sock *sk); |
482 | void (*to_sk_daddr)(union sctp_addr *, struct sock *sk); | 483 | void (*to_sk_daddr)(union sctp_addr *, struct sock *sk); |
diff --git a/include/net/sock.h b/include/net/sock.h index 5e5997654db6..03252d53975d 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -236,6 +236,7 @@ struct sock_common { | |||
236 | * @sk_shutdown: mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN | 236 | * @sk_shutdown: mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN |
237 | * @sk_userlocks: %SO_SNDBUF and %SO_RCVBUF settings | 237 | * @sk_userlocks: %SO_SNDBUF and %SO_RCVBUF settings |
238 | * @sk_lock: synchronizer | 238 | * @sk_lock: synchronizer |
239 | * @sk_kern_sock: True if sock is using kernel lock classes | ||
239 | * @sk_rcvbuf: size of receive buffer in bytes | 240 | * @sk_rcvbuf: size of receive buffer in bytes |
240 | * @sk_wq: sock wait queue and async head | 241 | * @sk_wq: sock wait queue and async head |
241 | * @sk_rx_dst: receive input route used by early demux | 242 | * @sk_rx_dst: receive input route used by early demux |
@@ -430,7 +431,8 @@ struct sock { | |||
430 | #endif | 431 | #endif |
431 | 432 | ||
432 | kmemcheck_bitfield_begin(flags); | 433 | kmemcheck_bitfield_begin(flags); |
433 | unsigned int sk_padding : 2, | 434 | unsigned int sk_padding : 1, |
435 | sk_kern_sock : 1, | ||
434 | sk_no_check_tx : 1, | 436 | sk_no_check_tx : 1, |
435 | sk_no_check_rx : 1, | 437 | sk_no_check_rx : 1, |
436 | sk_userlocks : 4, | 438 | sk_userlocks : 4, |
@@ -1015,7 +1017,8 @@ struct proto { | |||
1015 | int addr_len); | 1017 | int addr_len); |
1016 | int (*disconnect)(struct sock *sk, int flags); | 1018 | int (*disconnect)(struct sock *sk, int flags); |
1017 | 1019 | ||
1018 | struct sock * (*accept)(struct sock *sk, int flags, int *err); | 1020 | struct sock * (*accept)(struct sock *sk, int flags, int *err, |
1021 | bool kern); | ||
1019 | 1022 | ||
1020 | int (*ioctl)(struct sock *sk, int cmd, | 1023 | int (*ioctl)(struct sock *sk, int cmd, |
1021 | unsigned long arg); | 1024 | unsigned long arg); |
@@ -1573,7 +1576,7 @@ int sock_cmsg_send(struct sock *sk, struct msghdr *msg, | |||
1573 | int sock_no_bind(struct socket *, struct sockaddr *, int); | 1576 | int sock_no_bind(struct socket *, struct sockaddr *, int); |
1574 | int sock_no_connect(struct socket *, struct sockaddr *, int, int); | 1577 | int sock_no_connect(struct socket *, struct sockaddr *, int, int); |
1575 | int sock_no_socketpair(struct socket *, struct socket *); | 1578 | int sock_no_socketpair(struct socket *, struct socket *); |
1576 | int sock_no_accept(struct socket *, struct socket *, int); | 1579 | int sock_no_accept(struct socket *, struct socket *, int, bool); |
1577 | int sock_no_getname(struct socket *, struct sockaddr *, int *, int); | 1580 | int sock_no_getname(struct socket *, struct sockaddr *, int *, int); |
1578 | unsigned int sock_no_poll(struct file *, struct socket *, | 1581 | unsigned int sock_no_poll(struct file *, struct socket *, |
1579 | struct poll_table_struct *); | 1582 | struct poll_table_struct *); |
diff --git a/net/atm/svc.c b/net/atm/svc.c index db9794ec61d8..5589de7086af 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c | |||
@@ -318,7 +318,8 @@ out: | |||
318 | return error; | 318 | return error; |
319 | } | 319 | } |
320 | 320 | ||
321 | static int svc_accept(struct socket *sock, struct socket *newsock, int flags) | 321 | static int svc_accept(struct socket *sock, struct socket *newsock, int flags, |
322 | bool kern) | ||
322 | { | 323 | { |
323 | struct sock *sk = sock->sk; | 324 | struct sock *sk = sock->sk; |
324 | struct sk_buff *skb; | 325 | struct sk_buff *skb; |
@@ -329,7 +330,7 @@ static int svc_accept(struct socket *sock, struct socket *newsock, int flags) | |||
329 | 330 | ||
330 | lock_sock(sk); | 331 | lock_sock(sk); |
331 | 332 | ||
332 | error = svc_create(sock_net(sk), newsock, 0, 0); | 333 | error = svc_create(sock_net(sk), newsock, 0, kern); |
333 | if (error) | 334 | if (error) |
334 | goto out; | 335 | goto out; |
335 | 336 | ||
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index a8e42cedf1db..b7c486752b3a 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -1320,7 +1320,8 @@ out_release: | |||
1320 | return err; | 1320 | return err; |
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | static int ax25_accept(struct socket *sock, struct socket *newsock, int flags) | 1323 | static int ax25_accept(struct socket *sock, struct socket *newsock, int flags, |
1324 | bool kern) | ||
1324 | { | 1325 | { |
1325 | struct sk_buff *skb; | 1326 | struct sk_buff *skb; |
1326 | struct sock *newsk; | 1327 | struct sock *newsk; |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index f307b145ea54..507b80d59dec 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -301,7 +301,7 @@ done: | |||
301 | } | 301 | } |
302 | 302 | ||
303 | static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, | 303 | static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, |
304 | int flags) | 304 | int flags, bool kern) |
305 | { | 305 | { |
306 | DEFINE_WAIT_FUNC(wait, woken_wake_function); | 306 | DEFINE_WAIT_FUNC(wait, woken_wake_function); |
307 | struct sock *sk = sock->sk, *nsk; | 307 | struct sock *sk = sock->sk, *nsk; |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index aa1a814ceddc..ac3c650cb234 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -471,7 +471,8 @@ done: | |||
471 | return err; | 471 | return err; |
472 | } | 472 | } |
473 | 473 | ||
474 | static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags) | 474 | static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags, |
475 | bool kern) | ||
475 | { | 476 | { |
476 | DEFINE_WAIT_FUNC(wait, woken_wake_function); | 477 | DEFINE_WAIT_FUNC(wait, woken_wake_function); |
477 | struct sock *sk = sock->sk, *nsk; | 478 | struct sock *sk = sock->sk, *nsk; |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index e4e9a2da1e7e..728e0c8dc8e7 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -627,7 +627,7 @@ done: | |||
627 | } | 627 | } |
628 | 628 | ||
629 | static int sco_sock_accept(struct socket *sock, struct socket *newsock, | 629 | static int sco_sock_accept(struct socket *sock, struct socket *newsock, |
630 | int flags) | 630 | int flags, bool kern) |
631 | { | 631 | { |
632 | DEFINE_WAIT_FUNC(wait, woken_wake_function); | 632 | DEFINE_WAIT_FUNC(wait, woken_wake_function); |
633 | struct sock *sk = sock->sk, *ch; | 633 | struct sock *sk = sock->sk, *ch; |
diff --git a/net/core/sock.c b/net/core/sock.c index f6fd79f33097..a96d5f7a5734 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -197,66 +197,55 @@ EXPORT_SYMBOL(sk_net_capable); | |||
197 | 197 | ||
198 | /* | 198 | /* |
199 | * Each address family might have different locking rules, so we have | 199 | * Each address family might have different locking rules, so we have |
200 | * one slock key per address family: | 200 | * one slock key per address family and separate keys for internal and |
201 | * userspace sockets. | ||
201 | */ | 202 | */ |
202 | static struct lock_class_key af_family_keys[AF_MAX]; | 203 | static struct lock_class_key af_family_keys[AF_MAX]; |
204 | static struct lock_class_key af_family_kern_keys[AF_MAX]; | ||
203 | static struct lock_class_key af_family_slock_keys[AF_MAX]; | 205 | static struct lock_class_key af_family_slock_keys[AF_MAX]; |
206 | static struct lock_class_key af_family_kern_slock_keys[AF_MAX]; | ||
204 | 207 | ||
205 | /* | 208 | /* |
206 | * Make lock validator output more readable. (we pre-construct these | 209 | * Make lock validator output more readable. (we pre-construct these |
207 | * strings build-time, so that runtime initialization of socket | 210 | * strings build-time, so that runtime initialization of socket |
208 | * locks is fast): | 211 | * locks is fast): |
209 | */ | 212 | */ |
213 | |||
214 | #define _sock_locks(x) \ | ||
215 | x "AF_UNSPEC", x "AF_UNIX" , x "AF_INET" , \ | ||
216 | x "AF_AX25" , x "AF_IPX" , x "AF_APPLETALK", \ | ||
217 | x "AF_NETROM", x "AF_BRIDGE" , x "AF_ATMPVC" , \ | ||
218 | x "AF_X25" , x "AF_INET6" , x "AF_ROSE" , \ | ||
219 | x "AF_DECnet", x "AF_NETBEUI" , x "AF_SECURITY" , \ | ||
220 | x "AF_KEY" , x "AF_NETLINK" , x "AF_PACKET" , \ | ||
221 | x "AF_ASH" , x "AF_ECONET" , x "AF_ATMSVC" , \ | ||
222 | x "AF_RDS" , x "AF_SNA" , x "AF_IRDA" , \ | ||
223 | x "AF_PPPOX" , x "AF_WANPIPE" , x "AF_LLC" , \ | ||
224 | x "27" , x "28" , x "AF_CAN" , \ | ||
225 | x "AF_TIPC" , x "AF_BLUETOOTH", x "IUCV" , \ | ||
226 | x "AF_RXRPC" , x "AF_ISDN" , x "AF_PHONET" , \ | ||
227 | x "AF_IEEE802154", x "AF_CAIF" , x "AF_ALG" , \ | ||
228 | x "AF_NFC" , x "AF_VSOCK" , x "AF_KCM" , \ | ||
229 | x "AF_QIPCRTR", x "AF_SMC" , x "AF_MAX" | ||
230 | |||
210 | static const char *const af_family_key_strings[AF_MAX+1] = { | 231 | static const char *const af_family_key_strings[AF_MAX+1] = { |
211 | "sk_lock-AF_UNSPEC", "sk_lock-AF_UNIX" , "sk_lock-AF_INET" , | 232 | _sock_locks("sk_lock-") |
212 | "sk_lock-AF_AX25" , "sk_lock-AF_IPX" , "sk_lock-AF_APPLETALK", | ||
213 | "sk_lock-AF_NETROM", "sk_lock-AF_BRIDGE" , "sk_lock-AF_ATMPVC" , | ||
214 | "sk_lock-AF_X25" , "sk_lock-AF_INET6" , "sk_lock-AF_ROSE" , | ||
215 | "sk_lock-AF_DECnet", "sk_lock-AF_NETBEUI" , "sk_lock-AF_SECURITY" , | ||
216 | "sk_lock-AF_KEY" , "sk_lock-AF_NETLINK" , "sk_lock-AF_PACKET" , | ||
217 | "sk_lock-AF_ASH" , "sk_lock-AF_ECONET" , "sk_lock-AF_ATMSVC" , | ||
218 | "sk_lock-AF_RDS" , "sk_lock-AF_SNA" , "sk_lock-AF_IRDA" , | ||
219 | "sk_lock-AF_PPPOX" , "sk_lock-AF_WANPIPE" , "sk_lock-AF_LLC" , | ||
220 | "sk_lock-27" , "sk_lock-28" , "sk_lock-AF_CAN" , | ||
221 | "sk_lock-AF_TIPC" , "sk_lock-AF_BLUETOOTH", "sk_lock-IUCV" , | ||
222 | "sk_lock-AF_RXRPC" , "sk_lock-AF_ISDN" , "sk_lock-AF_PHONET" , | ||
223 | "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" , "sk_lock-AF_ALG" , | ||
224 | "sk_lock-AF_NFC" , "sk_lock-AF_VSOCK" , "sk_lock-AF_KCM" , | ||
225 | "sk_lock-AF_QIPCRTR", "sk_lock-AF_SMC" , "sk_lock-AF_MAX" | ||
226 | }; | 233 | }; |
227 | static const char *const af_family_slock_key_strings[AF_MAX+1] = { | 234 | static const char *const af_family_slock_key_strings[AF_MAX+1] = { |
228 | "slock-AF_UNSPEC", "slock-AF_UNIX" , "slock-AF_INET" , | 235 | _sock_locks("slock-") |
229 | "slock-AF_AX25" , "slock-AF_IPX" , "slock-AF_APPLETALK", | ||
230 | "slock-AF_NETROM", "slock-AF_BRIDGE" , "slock-AF_ATMPVC" , | ||
231 | "slock-AF_X25" , "slock-AF_INET6" , "slock-AF_ROSE" , | ||
232 | "slock-AF_DECnet", "slock-AF_NETBEUI" , "slock-AF_SECURITY" , | ||
233 | "slock-AF_KEY" , "slock-AF_NETLINK" , "slock-AF_PACKET" , | ||
234 | "slock-AF_ASH" , "slock-AF_ECONET" , "slock-AF_ATMSVC" , | ||
235 | "slock-AF_RDS" , "slock-AF_SNA" , "slock-AF_IRDA" , | ||
236 | "slock-AF_PPPOX" , "slock-AF_WANPIPE" , "slock-AF_LLC" , | ||
237 | "slock-27" , "slock-28" , "slock-AF_CAN" , | ||
238 | "slock-AF_TIPC" , "slock-AF_BLUETOOTH", "slock-AF_IUCV" , | ||
239 | "slock-AF_RXRPC" , "slock-AF_ISDN" , "slock-AF_PHONET" , | ||
240 | "slock-AF_IEEE802154", "slock-AF_CAIF" , "slock-AF_ALG" , | ||
241 | "slock-AF_NFC" , "slock-AF_VSOCK" ,"slock-AF_KCM" , | ||
242 | "slock-AF_QIPCRTR", "slock-AF_SMC" , "slock-AF_MAX" | ||
243 | }; | 236 | }; |
244 | static const char *const af_family_clock_key_strings[AF_MAX+1] = { | 237 | static const char *const af_family_clock_key_strings[AF_MAX+1] = { |
245 | "clock-AF_UNSPEC", "clock-AF_UNIX" , "clock-AF_INET" , | 238 | _sock_locks("clock-") |
246 | "clock-AF_AX25" , "clock-AF_IPX" , "clock-AF_APPLETALK", | 239 | }; |
247 | "clock-AF_NETROM", "clock-AF_BRIDGE" , "clock-AF_ATMPVC" , | 240 | |
248 | "clock-AF_X25" , "clock-AF_INET6" , "clock-AF_ROSE" , | 241 | static const char *const af_family_kern_key_strings[AF_MAX+1] = { |
249 | "clock-AF_DECnet", "clock-AF_NETBEUI" , "clock-AF_SECURITY" , | 242 | _sock_locks("k-sk_lock-") |
250 | "clock-AF_KEY" , "clock-AF_NETLINK" , "clock-AF_PACKET" , | 243 | }; |
251 | "clock-AF_ASH" , "clock-AF_ECONET" , "clock-AF_ATMSVC" , | 244 | static const char *const af_family_kern_slock_key_strings[AF_MAX+1] = { |
252 | "clock-AF_RDS" , "clock-AF_SNA" , "clock-AF_IRDA" , | 245 | _sock_locks("k-slock-") |
253 | "clock-AF_PPPOX" , "clock-AF_WANPIPE" , "clock-AF_LLC" , | 246 | }; |
254 | "clock-27" , "clock-28" , "clock-AF_CAN" , | 247 | static const char *const af_family_kern_clock_key_strings[AF_MAX+1] = { |
255 | "clock-AF_TIPC" , "clock-AF_BLUETOOTH", "clock-AF_IUCV" , | 248 | _sock_locks("k-clock-") |
256 | "clock-AF_RXRPC" , "clock-AF_ISDN" , "clock-AF_PHONET" , | ||
257 | "clock-AF_IEEE802154", "clock-AF_CAIF" , "clock-AF_ALG" , | ||
258 | "clock-AF_NFC" , "clock-AF_VSOCK" , "clock-AF_KCM" , | ||
259 | "clock-AF_QIPCRTR", "clock-AF_SMC" , "clock-AF_MAX" | ||
260 | }; | 249 | }; |
261 | 250 | ||
262 | /* | 251 | /* |
@@ -264,6 +253,7 @@ static const char *const af_family_clock_key_strings[AF_MAX+1] = { | |||
264 | * so split the lock classes by using a per-AF key: | 253 | * so split the lock classes by using a per-AF key: |
265 | */ | 254 | */ |
266 | static struct lock_class_key af_callback_keys[AF_MAX]; | 255 | static struct lock_class_key af_callback_keys[AF_MAX]; |
256 | static struct lock_class_key af_kern_callback_keys[AF_MAX]; | ||
267 | 257 | ||
268 | /* Take into consideration the size of the struct sk_buff overhead in the | 258 | /* Take into consideration the size of the struct sk_buff overhead in the |
269 | * determination of these values, since that is non-constant across | 259 | * determination of these values, since that is non-constant across |
@@ -1293,7 +1283,16 @@ lenout: | |||
1293 | */ | 1283 | */ |
1294 | static inline void sock_lock_init(struct sock *sk) | 1284 | static inline void sock_lock_init(struct sock *sk) |
1295 | { | 1285 | { |
1296 | sock_lock_init_class_and_name(sk, | 1286 | if (sk->sk_kern_sock) |
1287 | sock_lock_init_class_and_name( | ||
1288 | sk, | ||
1289 | af_family_kern_slock_key_strings[sk->sk_family], | ||
1290 | af_family_kern_slock_keys + sk->sk_family, | ||
1291 | af_family_kern_key_strings[sk->sk_family], | ||
1292 | af_family_kern_keys + sk->sk_family); | ||
1293 | else | ||
1294 | sock_lock_init_class_and_name( | ||
1295 | sk, | ||
1297 | af_family_slock_key_strings[sk->sk_family], | 1296 | af_family_slock_key_strings[sk->sk_family], |
1298 | af_family_slock_keys + sk->sk_family, | 1297 | af_family_slock_keys + sk->sk_family, |
1299 | af_family_key_strings[sk->sk_family], | 1298 | af_family_key_strings[sk->sk_family], |
@@ -1399,6 +1398,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, | |||
1399 | * why we need sk_prot_creator -acme | 1398 | * why we need sk_prot_creator -acme |
1400 | */ | 1399 | */ |
1401 | sk->sk_prot = sk->sk_prot_creator = prot; | 1400 | sk->sk_prot = sk->sk_prot_creator = prot; |
1401 | sk->sk_kern_sock = kern; | ||
1402 | sock_lock_init(sk); | 1402 | sock_lock_init(sk); |
1403 | sk->sk_net_refcnt = kern ? 0 : 1; | 1403 | sk->sk_net_refcnt = kern ? 0 : 1; |
1404 | if (likely(sk->sk_net_refcnt)) | 1404 | if (likely(sk->sk_net_refcnt)) |
@@ -2277,7 +2277,8 @@ int sock_no_socketpair(struct socket *sock1, struct socket *sock2) | |||
2277 | } | 2277 | } |
2278 | EXPORT_SYMBOL(sock_no_socketpair); | 2278 | EXPORT_SYMBOL(sock_no_socketpair); |
2279 | 2279 | ||
2280 | int sock_no_accept(struct socket *sock, struct socket *newsock, int flags) | 2280 | int sock_no_accept(struct socket *sock, struct socket *newsock, int flags, |
2281 | bool kern) | ||
2281 | { | 2282 | { |
2282 | return -EOPNOTSUPP; | 2283 | return -EOPNOTSUPP; |
2283 | } | 2284 | } |
@@ -2481,7 +2482,14 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
2481 | } | 2482 | } |
2482 | 2483 | ||
2483 | rwlock_init(&sk->sk_callback_lock); | 2484 | rwlock_init(&sk->sk_callback_lock); |
2484 | lockdep_set_class_and_name(&sk->sk_callback_lock, | 2485 | if (sk->sk_kern_sock) |
2486 | lockdep_set_class_and_name( | ||
2487 | &sk->sk_callback_lock, | ||
2488 | af_kern_callback_keys + sk->sk_family, | ||
2489 | af_family_kern_clock_key_strings[sk->sk_family]); | ||
2490 | else | ||
2491 | lockdep_set_class_and_name( | ||
2492 | &sk->sk_callback_lock, | ||
2485 | af_callback_keys + sk->sk_family, | 2493 | af_callback_keys + sk->sk_family, |
2486 | af_family_clock_key_strings[sk->sk_family]); | 2494 | af_family_clock_key_strings[sk->sk_family]); |
2487 | 2495 | ||
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index e6e79eda9763..7de5b40a5d0d 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
@@ -1070,7 +1070,8 @@ static struct sk_buff *dn_wait_for_connect(struct sock *sk, long *timeo) | |||
1070 | return skb == NULL ? ERR_PTR(err) : skb; | 1070 | return skb == NULL ? ERR_PTR(err) : skb; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | static int dn_accept(struct socket *sock, struct socket *newsock, int flags) | 1073 | static int dn_accept(struct socket *sock, struct socket *newsock, int flags, |
1074 | bool kern) | ||
1074 | { | 1075 | { |
1075 | struct sock *sk = sock->sk, *newsk; | 1076 | struct sock *sk = sock->sk, *newsk; |
1076 | struct sk_buff *skb = NULL; | 1077 | struct sk_buff *skb = NULL; |
@@ -1099,7 +1100,7 @@ static int dn_accept(struct socket *sock, struct socket *newsock, int flags) | |||
1099 | 1100 | ||
1100 | cb = DN_SKB_CB(skb); | 1101 | cb = DN_SKB_CB(skb); |
1101 | sk->sk_ack_backlog--; | 1102 | sk->sk_ack_backlog--; |
1102 | newsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, 0); | 1103 | newsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, kern); |
1103 | if (newsk == NULL) { | 1104 | if (newsk == NULL) { |
1104 | release_sock(sk); | 1105 | release_sock(sk); |
1105 | kfree_skb(skb); | 1106 | kfree_skb(skb); |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 5091f46826fa..6b1fc6e4278e 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -689,11 +689,12 @@ EXPORT_SYMBOL(inet_stream_connect); | |||
689 | * Accept a pending connection. The TCP layer now gives BSD semantics. | 689 | * Accept a pending connection. The TCP layer now gives BSD semantics. |
690 | */ | 690 | */ |
691 | 691 | ||
692 | int inet_accept(struct socket *sock, struct socket *newsock, int flags) | 692 | int inet_accept(struct socket *sock, struct socket *newsock, int flags, |
693 | bool kern) | ||
693 | { | 694 | { |
694 | struct sock *sk1 = sock->sk; | 695 | struct sock *sk1 = sock->sk; |
695 | int err = -EINVAL; | 696 | int err = -EINVAL; |
696 | struct sock *sk2 = sk1->sk_prot->accept(sk1, flags, &err); | 697 | struct sock *sk2 = sk1->sk_prot->accept(sk1, flags, &err, kern); |
697 | 698 | ||
698 | if (!sk2) | 699 | if (!sk2) |
699 | goto do_err; | 700 | goto do_err; |
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index b4d5980ade3b..5e313c1ac94f 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -424,7 +424,7 @@ static int inet_csk_wait_for_connect(struct sock *sk, long timeo) | |||
424 | /* | 424 | /* |
425 | * This will accept the next outstanding connection. | 425 | * This will accept the next outstanding connection. |
426 | */ | 426 | */ |
427 | struct sock *inet_csk_accept(struct sock *sk, int flags, int *err) | 427 | struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern) |
428 | { | 428 | { |
429 | struct inet_connection_sock *icsk = inet_csk(sk); | 429 | struct inet_connection_sock *icsk = inet_csk(sk); |
430 | struct request_sock_queue *queue = &icsk->icsk_accept_queue; | 430 | struct request_sock_queue *queue = &icsk->icsk_accept_queue; |
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 81adc29a448d..8d77ad5cadaf 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -828,7 +828,8 @@ out: | |||
828 | * Wait for incoming connection | 828 | * Wait for incoming connection |
829 | * | 829 | * |
830 | */ | 830 | */ |
831 | static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | 831 | static int irda_accept(struct socket *sock, struct socket *newsock, int flags, |
832 | bool kern) | ||
832 | { | 833 | { |
833 | struct sock *sk = sock->sk; | 834 | struct sock *sk = sock->sk; |
834 | struct irda_sock *new, *self = irda_sk(sk); | 835 | struct irda_sock *new, *self = irda_sk(sk); |
@@ -836,7 +837,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | |||
836 | struct sk_buff *skb = NULL; | 837 | struct sk_buff *skb = NULL; |
837 | int err; | 838 | int err; |
838 | 839 | ||
839 | err = irda_create(sock_net(sk), newsock, sk->sk_protocol, 0); | 840 | err = irda_create(sock_net(sk), newsock, sk->sk_protocol, kern); |
840 | if (err) | 841 | if (err) |
841 | return err; | 842 | return err; |
842 | 843 | ||
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 89bbde1081ce..84de7b6326dc 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -938,7 +938,7 @@ done: | |||
938 | 938 | ||
939 | /* Accept a pending connection */ | 939 | /* Accept a pending connection */ |
940 | static int iucv_sock_accept(struct socket *sock, struct socket *newsock, | 940 | static int iucv_sock_accept(struct socket *sock, struct socket *newsock, |
941 | int flags) | 941 | int flags, bool kern) |
942 | { | 942 | { |
943 | DECLARE_WAITQUEUE(wait, current); | 943 | DECLARE_WAITQUEUE(wait, current); |
944 | struct sock *sk = sock->sk, *nsk; | 944 | struct sock *sk = sock->sk, *nsk; |
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 06186d608a27..cb4fff785cbf 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c | |||
@@ -641,11 +641,13 @@ static void llc_cmsg_rcv(struct msghdr *msg, struct sk_buff *skb) | |||
641 | * @sock: Socket which connections arrive on. | 641 | * @sock: Socket which connections arrive on. |
642 | * @newsock: Socket to move incoming connection to. | 642 | * @newsock: Socket to move incoming connection to. |
643 | * @flags: User specified operational flags. | 643 | * @flags: User specified operational flags. |
644 | * @kern: If the socket is kernel internal | ||
644 | * | 645 | * |
645 | * Accept a new incoming connection. | 646 | * Accept a new incoming connection. |
646 | * Returns 0 upon success, negative otherwise. | 647 | * Returns 0 upon success, negative otherwise. |
647 | */ | 648 | */ |
648 | static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags) | 649 | static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags, |
650 | bool kern) | ||
649 | { | 651 | { |
650 | struct sock *sk = sock->sk, *newsk; | 652 | struct sock *sk = sock->sk, *newsk; |
651 | struct llc_sock *llc, *newllc; | 653 | struct llc_sock *llc, *newllc; |
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 4bbf4526b885..ebf16f7f9089 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
@@ -765,7 +765,8 @@ out_release: | |||
765 | return err; | 765 | return err; |
766 | } | 766 | } |
767 | 767 | ||
768 | static int nr_accept(struct socket *sock, struct socket *newsock, int flags) | 768 | static int nr_accept(struct socket *sock, struct socket *newsock, int flags, |
769 | bool kern) | ||
769 | { | 770 | { |
770 | struct sk_buff *skb; | 771 | struct sk_buff *skb; |
771 | struct sock *newsk; | 772 | struct sock *newsk; |
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index 879885b31cce..2ffb18e73df6 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c | |||
@@ -441,7 +441,7 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent, | |||
441 | } | 441 | } |
442 | 442 | ||
443 | static int llcp_sock_accept(struct socket *sock, struct socket *newsock, | 443 | static int llcp_sock_accept(struct socket *sock, struct socket *newsock, |
444 | int flags) | 444 | int flags, bool kern) |
445 | { | 445 | { |
446 | DECLARE_WAITQUEUE(wait, current); | 446 | DECLARE_WAITQUEUE(wait, current); |
447 | struct sock *sk = sock->sk, *new_sk; | 447 | struct sock *sk = sock->sk, *new_sk; |
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 222bedcd9575..e81537991ddf 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c | |||
@@ -772,7 +772,8 @@ static void pep_sock_close(struct sock *sk, long timeout) | |||
772 | sock_put(sk); | 772 | sock_put(sk); |
773 | } | 773 | } |
774 | 774 | ||
775 | static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp) | 775 | static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp, |
776 | bool kern) | ||
776 | { | 777 | { |
777 | struct pep_sock *pn = pep_sk(sk), *newpn; | 778 | struct pep_sock *pn = pep_sk(sk), *newpn; |
778 | struct sock *newsk = NULL; | 779 | struct sock *newsk = NULL; |
@@ -846,7 +847,8 @@ static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp) | |||
846 | } | 847 | } |
847 | 848 | ||
848 | /* Create a new to-be-accepted sock */ | 849 | /* Create a new to-be-accepted sock */ |
849 | newsk = sk_alloc(sock_net(sk), PF_PHONET, GFP_KERNEL, sk->sk_prot, 0); | 850 | newsk = sk_alloc(sock_net(sk), PF_PHONET, GFP_KERNEL, sk->sk_prot, |
851 | kern); | ||
850 | if (!newsk) { | 852 | if (!newsk) { |
851 | pep_reject_conn(sk, skb, PN_PIPE_ERR_OVERLOAD, GFP_KERNEL); | 853 | pep_reject_conn(sk, skb, PN_PIPE_ERR_OVERLOAD, GFP_KERNEL); |
852 | err = -ENOBUFS; | 854 | err = -ENOBUFS; |
diff --git a/net/phonet/socket.c b/net/phonet/socket.c index a6c8da3ee893..64634e3ec2fc 100644 --- a/net/phonet/socket.c +++ b/net/phonet/socket.c | |||
@@ -305,7 +305,7 @@ out: | |||
305 | } | 305 | } |
306 | 306 | ||
307 | static int pn_socket_accept(struct socket *sock, struct socket *newsock, | 307 | static int pn_socket_accept(struct socket *sock, struct socket *newsock, |
308 | int flags) | 308 | int flags, bool kern) |
309 | { | 309 | { |
310 | struct sock *sk = sock->sk; | 310 | struct sock *sk = sock->sk; |
311 | struct sock *newsk; | 311 | struct sock *newsk; |
@@ -314,7 +314,7 @@ static int pn_socket_accept(struct socket *sock, struct socket *newsock, | |||
314 | if (unlikely(sk->sk_state != TCP_LISTEN)) | 314 | if (unlikely(sk->sk_state != TCP_LISTEN)) |
315 | return -EINVAL; | 315 | return -EINVAL; |
316 | 316 | ||
317 | newsk = sk->sk_prot->accept(sk, flags, &err); | 317 | newsk = sk->sk_prot->accept(sk, flags, &err, kern); |
318 | if (!newsk) | 318 | if (!newsk) |
319 | return err; | 319 | return err; |
320 | 320 | ||
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c index 2c69a508a693..507678853e6c 100644 --- a/net/rds/tcp_listen.c +++ b/net/rds/tcp_listen.c | |||
@@ -133,7 +133,7 @@ int rds_tcp_accept_one(struct socket *sock) | |||
133 | 133 | ||
134 | new_sock->type = sock->type; | 134 | new_sock->type = sock->type; |
135 | new_sock->ops = sock->ops; | 135 | new_sock->ops = sock->ops; |
136 | ret = sock->ops->accept(sock, new_sock, O_NONBLOCK); | 136 | ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, true); |
137 | if (ret < 0) | 137 | if (ret < 0) |
138 | goto out; | 138 | goto out; |
139 | 139 | ||
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index b8a1df2c9785..4a9729257023 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -871,7 +871,8 @@ out_release: | |||
871 | return err; | 871 | return err; |
872 | } | 872 | } |
873 | 873 | ||
874 | static int rose_accept(struct socket *sock, struct socket *newsock, int flags) | 874 | static int rose_accept(struct socket *sock, struct socket *newsock, int flags, |
875 | bool kern) | ||
875 | { | 876 | { |
876 | struct sk_buff *skb; | 877 | struct sk_buff *skb; |
877 | struct sock *newsk; | 878 | struct sock *newsk; |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 063baac5b9fe..961ee59f696a 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -640,14 +640,15 @@ static sctp_scope_t sctp_v6_scope(union sctp_addr *addr) | |||
640 | 640 | ||
641 | /* Create and initialize a new sk for the socket to be returned by accept(). */ | 641 | /* Create and initialize a new sk for the socket to be returned by accept(). */ |
642 | static struct sock *sctp_v6_create_accept_sk(struct sock *sk, | 642 | static struct sock *sctp_v6_create_accept_sk(struct sock *sk, |
643 | struct sctp_association *asoc) | 643 | struct sctp_association *asoc, |
644 | bool kern) | ||
644 | { | 645 | { |
645 | struct sock *newsk; | 646 | struct sock *newsk; |
646 | struct ipv6_pinfo *newnp, *np = inet6_sk(sk); | 647 | struct ipv6_pinfo *newnp, *np = inet6_sk(sk); |
647 | struct sctp6_sock *newsctp6sk; | 648 | struct sctp6_sock *newsctp6sk; |
648 | struct ipv6_txoptions *opt; | 649 | struct ipv6_txoptions *opt; |
649 | 650 | ||
650 | newsk = sk_alloc(sock_net(sk), PF_INET6, GFP_KERNEL, sk->sk_prot, 0); | 651 | newsk = sk_alloc(sock_net(sk), PF_INET6, GFP_KERNEL, sk->sk_prot, kern); |
651 | if (!newsk) | 652 | if (!newsk) |
652 | goto out; | 653 | goto out; |
653 | 654 | ||
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 1b6d4574d2b0..989a900383b5 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -575,10 +575,11 @@ static int sctp_v4_is_ce(const struct sk_buff *skb) | |||
575 | 575 | ||
576 | /* Create and initialize a new sk for the socket returned by accept(). */ | 576 | /* Create and initialize a new sk for the socket returned by accept(). */ |
577 | static struct sock *sctp_v4_create_accept_sk(struct sock *sk, | 577 | static struct sock *sctp_v4_create_accept_sk(struct sock *sk, |
578 | struct sctp_association *asoc) | 578 | struct sctp_association *asoc, |
579 | bool kern) | ||
579 | { | 580 | { |
580 | struct sock *newsk = sk_alloc(sock_net(sk), PF_INET, GFP_KERNEL, | 581 | struct sock *newsk = sk_alloc(sock_net(sk), PF_INET, GFP_KERNEL, |
581 | sk->sk_prot, 0); | 582 | sk->sk_prot, kern); |
582 | struct inet_sock *newinet; | 583 | struct inet_sock *newinet; |
583 | 584 | ||
584 | if (!newsk) | 585 | if (!newsk) |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 6f0a9be50f50..0f378ea2ae38 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -4116,7 +4116,7 @@ static int sctp_disconnect(struct sock *sk, int flags) | |||
4116 | * descriptor will be returned from accept() to represent the newly | 4116 | * descriptor will be returned from accept() to represent the newly |
4117 | * formed association. | 4117 | * formed association. |
4118 | */ | 4118 | */ |
4119 | static struct sock *sctp_accept(struct sock *sk, int flags, int *err) | 4119 | static struct sock *sctp_accept(struct sock *sk, int flags, int *err, bool kern) |
4120 | { | 4120 | { |
4121 | struct sctp_sock *sp; | 4121 | struct sctp_sock *sp; |
4122 | struct sctp_endpoint *ep; | 4122 | struct sctp_endpoint *ep; |
@@ -4151,7 +4151,7 @@ static struct sock *sctp_accept(struct sock *sk, int flags, int *err) | |||
4151 | */ | 4151 | */ |
4152 | asoc = list_entry(ep->asocs.next, struct sctp_association, asocs); | 4152 | asoc = list_entry(ep->asocs.next, struct sctp_association, asocs); |
4153 | 4153 | ||
4154 | newsk = sp->pf->create_accept_sk(sk, asoc); | 4154 | newsk = sp->pf->create_accept_sk(sk, asoc, kern); |
4155 | if (!newsk) { | 4155 | if (!newsk) { |
4156 | error = -ENOMEM; | 4156 | error = -ENOMEM; |
4157 | goto out; | 4157 | goto out; |
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 85837ab90e89..093803786eac 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c | |||
@@ -944,7 +944,7 @@ out: | |||
944 | } | 944 | } |
945 | 945 | ||
946 | static int smc_accept(struct socket *sock, struct socket *new_sock, | 946 | static int smc_accept(struct socket *sock, struct socket *new_sock, |
947 | int flags) | 947 | int flags, bool kern) |
948 | { | 948 | { |
949 | struct sock *sk = sock->sk, *nsk; | 949 | struct sock *sk = sock->sk, *nsk; |
950 | DECLARE_WAITQUEUE(wait, current); | 950 | DECLARE_WAITQUEUE(wait, current); |
diff --git a/net/socket.c b/net/socket.c index e0757e648c0c..e034fe4164be 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -1506,7 +1506,7 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr, | |||
1506 | if (err) | 1506 | if (err) |
1507 | goto out_fd; | 1507 | goto out_fd; |
1508 | 1508 | ||
1509 | err = sock->ops->accept(sock, newsock, sock->file->f_flags); | 1509 | err = sock->ops->accept(sock, newsock, sock->file->f_flags, false); |
1510 | if (err < 0) | 1510 | if (err < 0) |
1511 | goto out_fd; | 1511 | goto out_fd; |
1512 | 1512 | ||
@@ -3239,7 +3239,7 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags) | |||
3239 | if (err < 0) | 3239 | if (err < 0) |
3240 | goto done; | 3240 | goto done; |
3241 | 3241 | ||
3242 | err = sock->ops->accept(sock, *newsock, flags); | 3242 | err = sock->ops->accept(sock, *newsock, flags, true); |
3243 | if (err < 0) { | 3243 | if (err < 0) { |
3244 | sock_release(*newsock); | 3244 | sock_release(*newsock); |
3245 | *newsock = NULL; | 3245 | *newsock = NULL; |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 43e4045e72bc..7130e73bd42c 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -115,7 +115,8 @@ static void tipc_data_ready(struct sock *sk); | |||
115 | static void tipc_write_space(struct sock *sk); | 115 | static void tipc_write_space(struct sock *sk); |
116 | static void tipc_sock_destruct(struct sock *sk); | 116 | static void tipc_sock_destruct(struct sock *sk); |
117 | static int tipc_release(struct socket *sock); | 117 | static int tipc_release(struct socket *sock); |
118 | static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags); | 118 | static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, |
119 | bool kern); | ||
119 | static void tipc_sk_timeout(unsigned long data); | 120 | static void tipc_sk_timeout(unsigned long data); |
120 | static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, | 121 | static int tipc_sk_publish(struct tipc_sock *tsk, uint scope, |
121 | struct tipc_name_seq const *seq); | 122 | struct tipc_name_seq const *seq); |
@@ -2029,7 +2030,8 @@ static int tipc_wait_for_accept(struct socket *sock, long timeo) | |||
2029 | * | 2030 | * |
2030 | * Returns 0 on success, errno otherwise | 2031 | * Returns 0 on success, errno otherwise |
2031 | */ | 2032 | */ |
2032 | static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) | 2033 | static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, |
2034 | bool kern) | ||
2033 | { | 2035 | { |
2034 | struct sock *new_sk, *sk = sock->sk; | 2036 | struct sock *new_sk, *sk = sock->sk; |
2035 | struct sk_buff *buf; | 2037 | struct sk_buff *buf; |
@@ -2051,7 +2053,7 @@ static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags) | |||
2051 | 2053 | ||
2052 | buf = skb_peek(&sk->sk_receive_queue); | 2054 | buf = skb_peek(&sk->sk_receive_queue); |
2053 | 2055 | ||
2054 | res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, 0); | 2056 | res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, kern); |
2055 | if (res) | 2057 | if (res) |
2056 | goto exit; | 2058 | goto exit; |
2057 | security_sk_clone(sock->sk, new_sock->sk); | 2059 | security_sk_clone(sock->sk, new_sock->sk); |
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index ee37b390260a..928691c43408 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -636,7 +636,7 @@ static int unix_bind(struct socket *, struct sockaddr *, int); | |||
636 | static int unix_stream_connect(struct socket *, struct sockaddr *, | 636 | static int unix_stream_connect(struct socket *, struct sockaddr *, |
637 | int addr_len, int flags); | 637 | int addr_len, int flags); |
638 | static int unix_socketpair(struct socket *, struct socket *); | 638 | static int unix_socketpair(struct socket *, struct socket *); |
639 | static int unix_accept(struct socket *, struct socket *, int); | 639 | static int unix_accept(struct socket *, struct socket *, int, bool); |
640 | static int unix_getname(struct socket *, struct sockaddr *, int *, int); | 640 | static int unix_getname(struct socket *, struct sockaddr *, int *, int); |
641 | static unsigned int unix_poll(struct file *, struct socket *, poll_table *); | 641 | static unsigned int unix_poll(struct file *, struct socket *, poll_table *); |
642 | static unsigned int unix_dgram_poll(struct file *, struct socket *, | 642 | static unsigned int unix_dgram_poll(struct file *, struct socket *, |
@@ -1402,7 +1402,8 @@ static void unix_sock_inherit_flags(const struct socket *old, | |||
1402 | set_bit(SOCK_PASSSEC, &new->flags); | 1402 | set_bit(SOCK_PASSSEC, &new->flags); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | static int unix_accept(struct socket *sock, struct socket *newsock, int flags) | 1405 | static int unix_accept(struct socket *sock, struct socket *newsock, int flags, |
1406 | bool kern) | ||
1406 | { | 1407 | { |
1407 | struct sock *sk = sock->sk; | 1408 | struct sock *sk = sock->sk; |
1408 | struct sock *tsk; | 1409 | struct sock *tsk; |
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 9192ead66751..9f770f33c100 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c | |||
@@ -1250,7 +1250,8 @@ out: | |||
1250 | return err; | 1250 | return err; |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | static int vsock_accept(struct socket *sock, struct socket *newsock, int flags) | 1253 | static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, |
1254 | bool kern) | ||
1254 | { | 1255 | { |
1255 | struct sock *listener; | 1256 | struct sock *listener; |
1256 | int err; | 1257 | int err; |
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index fd28a49dbe8f..8b911c29860e 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -852,7 +852,8 @@ static int x25_wait_for_data(struct sock *sk, long timeout) | |||
852 | return rc; | 852 | return rc; |
853 | } | 853 | } |
854 | 854 | ||
855 | static int x25_accept(struct socket *sock, struct socket *newsock, int flags) | 855 | static int x25_accept(struct socket *sock, struct socket *newsock, int flags, |
856 | bool kern) | ||
856 | { | 857 | { |
857 | struct sock *sk = sock->sk; | 858 | struct sock *sk = sock->sk; |
858 | struct sock *newsk; | 859 | struct sock *newsk; |