aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/802/psnap.c4
-rw-r--r--net/9p/trans_fd.c2
-rw-r--r--net/bridge/netfilter/ebtable_filter.c18
-rw-r--r--net/bridge/netfilter/ebtable_nat.c18
-rw-r--r--net/compat.c52
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/sysctl_net_core.c4
-rw-r--r--net/core/user_dma.c1
-rw-r--r--net/core/utils.c5
-rw-r--r--net/ipv4/af_inet.c13
-rw-r--r--net/ipv4/ipcomp.c4
-rw-r--r--net/ipv4/netfilter/arptable_filter.c39
-rw-r--r--net/ipv4/netfilter/iptable_security.c2
-rw-r--r--net/ipv4/route.c13
-rw-r--r--net/ipv4/sysctl_net_ipv4.c7
-rw-r--r--net/ipv6/af_inet6.c21
-rw-r--r--net/ipv6/ipcomp6.c4
-rw-r--r--net/ipv6/netfilter/ip6table_security.c2
-rw-r--r--net/ipv6/sysctl_net_ipv6.c16
-rw-r--r--net/iucv/iucv.c2
-rw-r--r--net/netfilter/nf_conntrack_extend.c10
-rw-r--r--net/sched/sch_atm.c4
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/socket.c144
-rw-r--r--net/sunrpc/rpc_pipe.c2
-rw-r--r--net/sunrpc/svc.c3
-rw-r--r--net/sunrpc/xprtrdma/svc_rdma_sendto.c3
-rw-r--r--net/sysctl_net.c38
-rw-r--r--net/unix/af_unix.c2
-rw-r--r--net/unix/garbage.c18
30 files changed, 322 insertions, 135 deletions
diff --git a/net/802/psnap.c b/net/802/psnap.c
index ea4643931446..b3cfe5a14fca 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -31,11 +31,9 @@ static struct llc_sap *snap_sap;
31 */ 31 */
32static struct datalink_proto *find_snap_client(unsigned char *desc) 32static struct datalink_proto *find_snap_client(unsigned char *desc)
33{ 33{
34 struct list_head *entry;
35 struct datalink_proto *proto = NULL, *p; 34 struct datalink_proto *proto = NULL, *p;
36 35
37 list_for_each_rcu(entry, &snap_list) { 36 list_for_each_entry_rcu(p, &snap_list, node) {
38 p = list_entry(entry, struct datalink_proto, node);
39 if (!memcmp(p->type, desc, 5)) { 37 if (!memcmp(p->type, desc, 5)) {
40 proto = p; 38 proto = p;
41 break; 39 break;
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 4507f744f44e..cdf137af7adc 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -1285,7 +1285,7 @@ static int p9_socket_open(struct p9_trans *trans, struct socket *csocket)
1285 int fd, ret; 1285 int fd, ret;
1286 1286
1287 csocket->sk->sk_allocation = GFP_NOIO; 1287 csocket->sk->sk_allocation = GFP_NOIO;
1288 fd = sock_map_fd(csocket); 1288 fd = sock_map_fd(csocket, 0);
1289 if (fd < 0) { 1289 if (fd < 0) {
1290 P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n"); 1290 P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n");
1291 return fd; 1291 return fd;
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 690bc3ab186c..1a58af51a2e2 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -93,28 +93,20 @@ static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
93 93
94static int __init ebtable_filter_init(void) 94static int __init ebtable_filter_init(void)
95{ 95{
96 int i, j, ret; 96 int ret;
97 97
98 ret = ebt_register_table(&frame_filter); 98 ret = ebt_register_table(&frame_filter);
99 if (ret < 0) 99 if (ret < 0)
100 return ret; 100 return ret;
101 for (i = 0; i < ARRAY_SIZE(ebt_ops_filter); i++) 101 ret = nf_register_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
102 if ((ret = nf_register_hook(&ebt_ops_filter[i])) < 0) 102 if (ret < 0)
103 goto cleanup; 103 ebt_unregister_table(&frame_filter);
104 return ret;
105cleanup:
106 for (j = 0; j < i; j++)
107 nf_unregister_hook(&ebt_ops_filter[j]);
108 ebt_unregister_table(&frame_filter);
109 return ret; 104 return ret;
110} 105}
111 106
112static void __exit ebtable_filter_fini(void) 107static void __exit ebtable_filter_fini(void)
113{ 108{
114 int i; 109 nf_unregister_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
115
116 for (i = 0; i < ARRAY_SIZE(ebt_ops_filter); i++)
117 nf_unregister_hook(&ebt_ops_filter[i]);
118 ebt_unregister_table(&frame_filter); 110 ebt_unregister_table(&frame_filter);
119} 111}
120 112
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index 5b495fe2d0b6..f60c1e78e575 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -100,28 +100,20 @@ static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
100 100
101static int __init ebtable_nat_init(void) 101static int __init ebtable_nat_init(void)
102{ 102{
103 int i, ret, j; 103 int ret;
104 104
105 ret = ebt_register_table(&frame_nat); 105 ret = ebt_register_table(&frame_nat);
106 if (ret < 0) 106 if (ret < 0)
107 return ret; 107 return ret;
108 for (i = 0; i < ARRAY_SIZE(ebt_ops_nat); i++) 108 ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
109 if ((ret = nf_register_hook(&ebt_ops_nat[i])) < 0) 109 if (ret < 0)
110 goto cleanup; 110 ebt_unregister_table(&frame_nat);
111 return ret;
112cleanup:
113 for (j = 0; j < i; j++)
114 nf_unregister_hook(&ebt_ops_nat[j]);
115 ebt_unregister_table(&frame_nat);
116 return ret; 111 return ret;
117} 112}
118 113
119static void __exit ebtable_nat_fini(void) 114static void __exit ebtable_nat_fini(void)
120{ 115{
121 int i; 116 nf_unregister_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
122
123 for (i = 0; i < ARRAY_SIZE(ebt_ops_nat); i++)
124 nf_unregister_hook(&ebt_ops_nat[i]);
125 ebt_unregister_table(&frame_nat); 117 ebt_unregister_table(&frame_nat);
126} 118}
127 119
diff --git a/net/compat.c b/net/compat.c
index 6e1b03b51933..67fb6a3834a3 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -722,9 +722,10 @@ EXPORT_SYMBOL(compat_mc_getsockopt);
722 722
723/* Argument list sizes for compat_sys_socketcall */ 723/* Argument list sizes for compat_sys_socketcall */
724#define AL(x) ((x) * sizeof(u32)) 724#define AL(x) ((x) * sizeof(u32))
725static unsigned char nas[18]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), 725static unsigned char nas[19]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
726 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), 726 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
727 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3)}; 727 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
728 AL(6)};
728#undef AL 729#undef AL
729 730
730asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags) 731asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags)
@@ -737,13 +738,52 @@ asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, uns
737 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT); 738 return sys_recvmsg(fd, (struct msghdr __user *)msg, flags | MSG_CMSG_COMPAT);
738} 739}
739 740
741asmlinkage long compat_sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
742 int __user *upeer_addrlen,
743 const compat_sigset_t __user *sigmask,
744 compat_size_t sigsetsize, int flags)
745{
746 compat_sigset_t ss32;
747 sigset_t ksigmask, sigsaved;
748 int ret;
749
750 if (sigmask) {
751 if (sigsetsize != sizeof(compat_sigset_t))
752 return -EINVAL;
753 if (copy_from_user(&ss32, sigmask, sizeof(ss32)))
754 return -EFAULT;
755 sigset_from_compat(&ksigmask, &ss32);
756
757 sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP));
758 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
759 }
760
761 ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
762
763 if (ret == -ERESTARTNOHAND) {
764 /*
765 * Don't restore the signal mask yet. Let do_signal() deliver
766 * the signal on the way back to userspace, before the signal
767 * mask is restored.
768 */
769 if (sigmask) {
770 memcpy(&current->saved_sigmask, &sigsaved,
771 sizeof(sigsaved));
772 set_restore_sigmask();
773 }
774 } else if (sigmask)
775 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
776
777 return ret;
778}
779
740asmlinkage long compat_sys_socketcall(int call, u32 __user *args) 780asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
741{ 781{
742 int ret; 782 int ret;
743 u32 a[6]; 783 u32 a[6];
744 u32 a0, a1; 784 u32 a0, a1;
745 785
746 if (call < SYS_SOCKET || call > SYS_RECVMSG) 786 if (call < SYS_SOCKET || call > SYS_PACCEPT)
747 return -EINVAL; 787 return -EINVAL;
748 if (copy_from_user(a, args, nas[call])) 788 if (copy_from_user(a, args, nas[call]))
749 return -EFAULT; 789 return -EFAULT;
@@ -764,7 +804,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
764 ret = sys_listen(a0, a1); 804 ret = sys_listen(a0, a1);
765 break; 805 break;
766 case SYS_ACCEPT: 806 case SYS_ACCEPT:
767 ret = sys_accept(a0, compat_ptr(a1), compat_ptr(a[2])); 807 ret = do_accept(a0, compat_ptr(a1), compat_ptr(a[2]), 0);
768 break; 808 break;
769 case SYS_GETSOCKNAME: 809 case SYS_GETSOCKNAME:
770 ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2])); 810 ret = sys_getsockname(a0, compat_ptr(a1), compat_ptr(a[2]));
@@ -804,6 +844,10 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
804 case SYS_RECVMSG: 844 case SYS_RECVMSG:
805 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]); 845 ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]);
806 break; 846 break;
847 case SYS_PACCEPT:
848 ret = compat_sys_paccept(a0, compat_ptr(a1), compat_ptr(a[2]),
849 compat_ptr(a[3]), a[4], a[5]);
850 break;
807 default: 851 default:
808 ret = -EINVAL; 852 ret = -EINVAL;
809 break; 853 break;
diff --git a/net/core/dev.c b/net/core/dev.c
index c6f9c83745e6..8d13a9b9f1df 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2395,7 +2395,7 @@ out:
2395 */ 2395 */
2396 if (!cpus_empty(net_dma.channel_mask)) { 2396 if (!cpus_empty(net_dma.channel_mask)) {
2397 int chan_idx; 2397 int chan_idx;
2398 for_each_cpu_mask(chan_idx, net_dma.channel_mask) { 2398 for_each_cpu_mask_nr(chan_idx, net_dma.channel_mask) {
2399 struct dma_chan *chan = net_dma.channels[chan_idx]; 2399 struct dma_chan *chan = net_dma.channels[chan_idx];
2400 if (chan) 2400 if (chan)
2401 dma_async_memcpy_issue_pending(chan); 2401 dma_async_memcpy_issue_pending(chan);
@@ -4530,7 +4530,7 @@ static void net_dma_rebalance(struct net_dma *net_dma)
4530 i = 0; 4530 i = 0;
4531 cpu = first_cpu(cpu_online_map); 4531 cpu = first_cpu(cpu_online_map);
4532 4532
4533 for_each_cpu_mask(chan_idx, net_dma->channel_mask) { 4533 for_each_cpu_mask_nr(chan_idx, net_dma->channel_mask) {
4534 chan = net_dma->channels[chan_idx]; 4534 chan = net_dma->channels[chan_idx];
4535 4535
4536 n = ((num_online_cpus() / cpus_weight(net_dma->channel_mask)) 4536 n = ((num_online_cpus() / cpus_weight(net_dma->channel_mask))
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index a570e2af22cb..f686467ff12b 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -67,7 +67,7 @@ static struct ctl_table net_core_table[] = {
67 { 67 {
68 .ctl_name = NET_CORE_MSG_COST, 68 .ctl_name = NET_CORE_MSG_COST,
69 .procname = "message_cost", 69 .procname = "message_cost",
70 .data = &net_msg_cost, 70 .data = &net_ratelimit_state.interval,
71 .maxlen = sizeof(int), 71 .maxlen = sizeof(int),
72 .mode = 0644, 72 .mode = 0644,
73 .proc_handler = &proc_dointvec_jiffies, 73 .proc_handler = &proc_dointvec_jiffies,
@@ -76,7 +76,7 @@ static struct ctl_table net_core_table[] = {
76 { 76 {
77 .ctl_name = NET_CORE_MSG_BURST, 77 .ctl_name = NET_CORE_MSG_BURST,
78 .procname = "message_burst", 78 .procname = "message_burst",
79 .data = &net_msg_burst, 79 .data = &net_ratelimit_state.burst,
80 .maxlen = sizeof(int), 80 .maxlen = sizeof(int),
81 .mode = 0644, 81 .mode = 0644,
82 .proc_handler = &proc_dointvec, 82 .proc_handler = &proc_dointvec,
diff --git a/net/core/user_dma.c b/net/core/user_dma.c
index 53c6b67b2877..164b090d5ac3 100644
--- a/net/core/user_dma.c
+++ b/net/core/user_dma.c
@@ -33,6 +33,7 @@
33#define NET_DMA_DEFAULT_COPYBREAK 4096 33#define NET_DMA_DEFAULT_COPYBREAK 4096
34 34
35int sysctl_tcp_dma_copybreak = NET_DMA_DEFAULT_COPYBREAK; 35int sysctl_tcp_dma_copybreak = NET_DMA_DEFAULT_COPYBREAK;
36EXPORT_SYMBOL(sysctl_tcp_dma_copybreak);
36 37
37/** 38/**
38 * dma_skb_copy_datagram_iovec - Copy a datagram to an iovec. 39 * dma_skb_copy_datagram_iovec - Copy a datagram to an iovec.
diff --git a/net/core/utils.c b/net/core/utils.c
index 8031eb59054e..72e0ebe964a0 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -31,17 +31,16 @@
31#include <asm/system.h> 31#include <asm/system.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33 33
34int net_msg_cost __read_mostly = 5*HZ;
35int net_msg_burst __read_mostly = 10;
36int net_msg_warn __read_mostly = 1; 34int net_msg_warn __read_mostly = 1;
37EXPORT_SYMBOL(net_msg_warn); 35EXPORT_SYMBOL(net_msg_warn);
38 36
37DEFINE_RATELIMIT_STATE(net_ratelimit_state, 5 * HZ, 10);
39/* 38/*
40 * All net warning printk()s should be guarded by this function. 39 * All net warning printk()s should be guarded by this function.
41 */ 40 */
42int net_ratelimit(void) 41int net_ratelimit(void)
43{ 42{
44 return __printk_ratelimit(net_msg_cost, net_msg_burst); 43 return __ratelimit(&net_ratelimit_state);
45} 44}
46EXPORT_SYMBOL(net_ratelimit); 45EXPORT_SYMBOL(net_ratelimit);
47 46
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index a107f49eea41..8a3ac1fa71a9 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -264,7 +264,6 @@ static inline int inet_netns_ok(struct net *net, int protocol)
264static int inet_create(struct net *net, struct socket *sock, int protocol) 264static int inet_create(struct net *net, struct socket *sock, int protocol)
265{ 265{
266 struct sock *sk; 266 struct sock *sk;
267 struct list_head *p;
268 struct inet_protosw *answer; 267 struct inet_protosw *answer;
269 struct inet_sock *inet; 268 struct inet_sock *inet;
270 struct proto *answer_prot; 269 struct proto *answer_prot;
@@ -281,13 +280,12 @@ static int inet_create(struct net *net, struct socket *sock, int protocol)
281 sock->state = SS_UNCONNECTED; 280 sock->state = SS_UNCONNECTED;
282 281
283 /* Look for the requested type/protocol pair. */ 282 /* Look for the requested type/protocol pair. */
284 answer = NULL;
285lookup_protocol: 283lookup_protocol:
286 err = -ESOCKTNOSUPPORT; 284 err = -ESOCKTNOSUPPORT;
287 rcu_read_lock(); 285 rcu_read_lock();
288 list_for_each_rcu(p, &inetsw[sock->type]) { 286 list_for_each_entry_rcu(answer, &inetsw[sock->type], list) {
289 answer = list_entry(p, struct inet_protosw, list);
290 287
288 err = 0;
291 /* Check the non-wild match. */ 289 /* Check the non-wild match. */
292 if (protocol == answer->protocol) { 290 if (protocol == answer->protocol) {
293 if (protocol != IPPROTO_IP) 291 if (protocol != IPPROTO_IP)
@@ -302,10 +300,9 @@ lookup_protocol:
302 break; 300 break;
303 } 301 }
304 err = -EPROTONOSUPPORT; 302 err = -EPROTONOSUPPORT;
305 answer = NULL;
306 } 303 }
307 304
308 if (unlikely(answer == NULL)) { 305 if (unlikely(err)) {
309 if (try_loading_module < 2) { 306 if (try_loading_module < 2) {
310 rcu_read_unlock(); 307 rcu_read_unlock();
311 /* 308 /*
@@ -1442,6 +1439,10 @@ static int __init inet_init(void)
1442 1439
1443 (void)sock_register(&inet_family_ops); 1440 (void)sock_register(&inet_family_ops);
1444 1441
1442#ifdef CONFIG_SYSCTL
1443 ip_static_sysctl_init();
1444#endif
1445
1445 /* 1446 /*
1446 * Add all the base protocols. 1447 * Add all the base protocols.
1447 */ 1448 */
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index a42b64d040c4..38ccb6dfb02e 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -104,9 +104,7 @@ out:
104 104
105static int ipcomp4_init_state(struct xfrm_state *x) 105static int ipcomp4_init_state(struct xfrm_state *x)
106{ 106{
107 int err; 107 int err = -EINVAL;
108 struct ipcomp_data *ipcd;
109 struct xfrm_algo_desc *calg_desc;
110 108
111 x->props.header_len = 0; 109 x->props.header_len = 0;
112 switch (x->props.mode) { 110 switch (x->props.mode) {
diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index 3be4d07e7ed9..082f5dd3156c 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -55,32 +55,53 @@ static struct xt_table packet_filter = {
55}; 55};
56 56
57/* The work comes in here from netfilter.c */ 57/* The work comes in here from netfilter.c */
58static unsigned int arpt_hook(unsigned int hook, 58static unsigned int arpt_in_hook(unsigned int hook,
59 struct sk_buff *skb, 59 struct sk_buff *skb,
60 const struct net_device *in, 60 const struct net_device *in,
61 const struct net_device *out, 61 const struct net_device *out,
62 int (*okfn)(struct sk_buff *)) 62 int (*okfn)(struct sk_buff *))
63{ 63{
64 return arpt_do_table(skb, hook, in, out, init_net.ipv4.arptable_filter); 64 return arpt_do_table(skb, hook, in, out,
65 dev_net(in)->ipv4.arptable_filter);
66}
67
68static unsigned int arpt_out_hook(unsigned int hook,
69 struct sk_buff *skb,
70 const struct net_device *in,
71 const struct net_device *out,
72 int (*okfn)(struct sk_buff *))
73{
74 return arpt_do_table(skb, hook, in, out,
75 dev_net(out)->ipv4.arptable_filter);
76}
77
78static unsigned int arpt_forward_hook(unsigned int hook,
79 struct sk_buff *skb,
80 const struct net_device *in,
81 const struct net_device *out,
82 int (*okfn)(struct sk_buff *))
83{
84 return arpt_do_table(skb, hook, in, out,
85 dev_net(in)->ipv4.arptable_filter);
65} 86}
66 87
67static struct nf_hook_ops arpt_ops[] __read_mostly = { 88static struct nf_hook_ops arpt_ops[] __read_mostly = {
68 { 89 {
69 .hook = arpt_hook, 90 .hook = arpt_in_hook,
70 .owner = THIS_MODULE, 91 .owner = THIS_MODULE,
71 .pf = NF_ARP, 92 .pf = NF_ARP,
72 .hooknum = NF_ARP_IN, 93 .hooknum = NF_ARP_IN,
73 .priority = NF_IP_PRI_FILTER, 94 .priority = NF_IP_PRI_FILTER,
74 }, 95 },
75 { 96 {
76 .hook = arpt_hook, 97 .hook = arpt_out_hook,
77 .owner = THIS_MODULE, 98 .owner = THIS_MODULE,
78 .pf = NF_ARP, 99 .pf = NF_ARP,
79 .hooknum = NF_ARP_OUT, 100 .hooknum = NF_ARP_OUT,
80 .priority = NF_IP_PRI_FILTER, 101 .priority = NF_IP_PRI_FILTER,
81 }, 102 },
82 { 103 {
83 .hook = arpt_hook, 104 .hook = arpt_forward_hook,
84 .owner = THIS_MODULE, 105 .owner = THIS_MODULE,
85 .pf = NF_ARP, 106 .pf = NF_ARP,
86 .hooknum = NF_ARP_FORWARD, 107 .hooknum = NF_ARP_FORWARD,
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c
index 2b472ac2263a..db6d312128e1 100644
--- a/net/ipv4/netfilter/iptable_security.c
+++ b/net/ipv4/netfilter/iptable_security.c
@@ -32,7 +32,7 @@ static struct
32 struct ipt_replace repl; 32 struct ipt_replace repl;
33 struct ipt_standard entries[3]; 33 struct ipt_standard entries[3];
34 struct ipt_error term; 34 struct ipt_error term;
35} initial_table __initdata = { 35} initial_table __net_initdata = {
36 .repl = { 36 .repl = {
37 .name = "security", 37 .name = "security",
38 .valid_hooks = SECURITY_VALID_HOOKS, 38 .valid_hooks = SECURITY_VALID_HOOKS,
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index e4ab0ac94f92..380d6474cf66 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1502,7 +1502,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1502 rth->fl.iif != 0 || 1502 rth->fl.iif != 0 ||
1503 dst_metric_locked(&rth->u.dst, RTAX_MTU) || 1503 dst_metric_locked(&rth->u.dst, RTAX_MTU) ||
1504 !net_eq(dev_net(rth->u.dst.dev), net) || 1504 !net_eq(dev_net(rth->u.dst.dev), net) ||
1505 !rt_is_expired(rth)) 1505 rt_is_expired(rth))
1506 continue; 1506 continue;
1507 1507
1508 if (new_mtu < 68 || new_mtu >= old_mtu) { 1508 if (new_mtu < 68 || new_mtu >= old_mtu) {
@@ -2914,7 +2914,7 @@ static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table,
2914 return 0; 2914 return 0;
2915} 2915}
2916 2916
2917ctl_table ipv4_route_table[] = { 2917static ctl_table ipv4_route_table[] = {
2918 { 2918 {
2919 .ctl_name = NET_IPV4_ROUTE_GC_THRESH, 2919 .ctl_name = NET_IPV4_ROUTE_GC_THRESH,
2920 .procname = "gc_thresh", 2920 .procname = "gc_thresh",
@@ -3216,6 +3216,15 @@ int __init ip_rt_init(void)
3216 return rc; 3216 return rc;
3217} 3217}
3218 3218
3219/*
3220 * We really need to sanitize the damn ipv4 init order, then all
3221 * this nonsense will go away.
3222 */
3223void __init ip_static_sysctl_init(void)
3224{
3225 register_sysctl_paths(ipv4_route_path, ipv4_route_table);
3226}
3227
3219EXPORT_SYMBOL(__ip_select_ident); 3228EXPORT_SYMBOL(__ip_select_ident);
3220EXPORT_SYMBOL(ip_route_input); 3229EXPORT_SYMBOL(ip_route_input);
3221EXPORT_SYMBOL(ip_route_output_key); 3230EXPORT_SYMBOL(ip_route_output_key);
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 14ef202a2254..770d827f5ab8 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -401,13 +401,6 @@ static struct ctl_table ipv4_table[] = {
401 .proc_handler = &ipv4_local_port_range, 401 .proc_handler = &ipv4_local_port_range,
402 .strategy = &ipv4_sysctl_local_port_range, 402 .strategy = &ipv4_sysctl_local_port_range,
403 }, 403 },
404 {
405 .ctl_name = NET_IPV4_ROUTE,
406 .procname = "route",
407 .maxlen = 0,
408 .mode = 0555,
409 .child = ipv4_route_table
410 },
411#ifdef CONFIG_IP_MULTICAST 404#ifdef CONFIG_IP_MULTICAST
412 { 405 {
413 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS, 406 .ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 0843c4d6218c..95055f8c3f35 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -83,7 +83,6 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
83 struct inet_sock *inet; 83 struct inet_sock *inet;
84 struct ipv6_pinfo *np; 84 struct ipv6_pinfo *np;
85 struct sock *sk; 85 struct sock *sk;
86 struct list_head *p;
87 struct inet_protosw *answer; 86 struct inet_protosw *answer;
88 struct proto *answer_prot; 87 struct proto *answer_prot;
89 unsigned char answer_flags; 88 unsigned char answer_flags;
@@ -97,13 +96,12 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
97 build_ehash_secret(); 96 build_ehash_secret();
98 97
99 /* Look for the requested type/protocol pair. */ 98 /* Look for the requested type/protocol pair. */
100 answer = NULL;
101lookup_protocol: 99lookup_protocol:
102 err = -ESOCKTNOSUPPORT; 100 err = -ESOCKTNOSUPPORT;
103 rcu_read_lock(); 101 rcu_read_lock();
104 list_for_each_rcu(p, &inetsw6[sock->type]) { 102 list_for_each_entry_rcu(answer, &inetsw6[sock->type], list) {
105 answer = list_entry(p, struct inet_protosw, list);
106 103
104 err = 0;
107 /* Check the non-wild match. */ 105 /* Check the non-wild match. */
108 if (protocol == answer->protocol) { 106 if (protocol == answer->protocol) {
109 if (protocol != IPPROTO_IP) 107 if (protocol != IPPROTO_IP)
@@ -118,10 +116,9 @@ lookup_protocol:
118 break; 116 break;
119 } 117 }
120 err = -EPROTONOSUPPORT; 118 err = -EPROTONOSUPPORT;
121 answer = NULL;
122 } 119 }
123 120
124 if (!answer) { 121 if (err) {
125 if (try_loading_module < 2) { 122 if (try_loading_module < 2) {
126 rcu_read_unlock(); 123 rcu_read_unlock();
127 /* 124 /*
@@ -937,6 +934,11 @@ static int __init inet6_init(void)
937 if (err) 934 if (err)
938 goto out_unregister_sock; 935 goto out_unregister_sock;
939 936
937#ifdef CONFIG_SYSCTL
938 err = ipv6_static_sysctl_register();
939 if (err)
940 goto static_sysctl_fail;
941#endif
940 /* 942 /*
941 * ipngwg API draft makes clear that the correct semantics 943 * ipngwg API draft makes clear that the correct semantics
942 * for TCP and UDP is to consider one TCP and UDP instance 944 * for TCP and UDP is to consider one TCP and UDP instance
@@ -1061,6 +1063,10 @@ ipmr_fail:
1061icmp_fail: 1063icmp_fail:
1062 unregister_pernet_subsys(&inet6_net_ops); 1064 unregister_pernet_subsys(&inet6_net_ops);
1063register_pernet_fail: 1065register_pernet_fail:
1066#ifdef CONFIG_SYSCTL
1067 ipv6_static_sysctl_unregister();
1068static_sysctl_fail:
1069#endif
1064 cleanup_ipv6_mibs(); 1070 cleanup_ipv6_mibs();
1065out_unregister_sock: 1071out_unregister_sock:
1066 sock_unregister(PF_INET6); 1072 sock_unregister(PF_INET6);
@@ -1116,6 +1122,9 @@ static void __exit inet6_exit(void)
1116 rawv6_exit(); 1122 rawv6_exit();
1117 1123
1118 unregister_pernet_subsys(&inet6_net_ops); 1124 unregister_pernet_subsys(&inet6_net_ops);
1125#ifdef CONFIG_SYSCTL
1126 ipv6_static_sysctl_unregister();
1127#endif
1119 cleanup_ipv6_mibs(); 1128 cleanup_ipv6_mibs();
1120 proto_unregister(&rawv6_prot); 1129 proto_unregister(&rawv6_prot);
1121 proto_unregister(&udplitev6_prot); 1130 proto_unregister(&udplitev6_prot);
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 0cfcea42153a..4545e4306862 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -134,9 +134,7 @@ out:
134 134
135static int ipcomp6_init_state(struct xfrm_state *x) 135static int ipcomp6_init_state(struct xfrm_state *x)
136{ 136{
137 int err; 137 int err = -EINVAL;
138 struct ipcomp_data *ipcd;
139 struct xfrm_algo_desc *calg_desc;
140 138
141 x->props.header_len = 0; 139 x->props.header_len = 0;
142 switch (x->props.mode) { 140 switch (x->props.mode) {
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c
index a07abee30497..6e7131036bc6 100644
--- a/net/ipv6/netfilter/ip6table_security.c
+++ b/net/ipv6/netfilter/ip6table_security.c
@@ -31,7 +31,7 @@ static struct
31 struct ip6t_replace repl; 31 struct ip6t_replace repl;
32 struct ip6t_standard entries[3]; 32 struct ip6t_standard entries[3];
33 struct ip6t_error term; 33 struct ip6t_error term;
34} initial_table __initdata = { 34} initial_table __net_initdata = {
35 .repl = { 35 .repl = {
36 .name = "security", 36 .name = "security",
37 .valid_hooks = SECURITY_VALID_HOOKS, 37 .valid_hooks = SECURITY_VALID_HOOKS,
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 5c99274558bf..e6dfaeac6be3 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -150,3 +150,19 @@ void ipv6_sysctl_unregister(void)
150 unregister_net_sysctl_table(ip6_header); 150 unregister_net_sysctl_table(ip6_header);
151 unregister_pernet_subsys(&ipv6_sysctl_net_ops); 151 unregister_pernet_subsys(&ipv6_sysctl_net_ops);
152} 152}
153
154static struct ctl_table_header *ip6_base;
155
156int ipv6_static_sysctl_register(void)
157{
158 static struct ctl_table empty[1];
159 ip6_base = register_net_sysctl_rotable(net_ipv6_ctl_path, empty);
160 if (ip6_base == NULL)
161 return -ENOMEM;
162 return 0;
163}
164
165void ipv6_static_sysctl_unregister(void)
166{
167 unregister_net_sysctl_table(ip6_base);
168}
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index 265b1b289a32..705959b31e24 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -497,7 +497,7 @@ static void iucv_setmask_up(void)
497 /* Disable all cpu but the first in cpu_irq_cpumask. */ 497 /* Disable all cpu but the first in cpu_irq_cpumask. */
498 cpumask = iucv_irq_cpumask; 498 cpumask = iucv_irq_cpumask;
499 cpu_clear(first_cpu(iucv_irq_cpumask), cpumask); 499 cpu_clear(first_cpu(iucv_irq_cpumask), cpumask);
500 for_each_cpu_mask(cpu, cpumask) 500 for_each_cpu_mask_nr(cpu, cpumask)
501 smp_call_function_single(cpu, iucv_block_cpu, NULL, 1); 501 smp_call_function_single(cpu, iucv_block_cpu, NULL, 1);
502} 502}
503 503
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c
index 3469bc71a385..4b2c769d555f 100644
--- a/net/netfilter/nf_conntrack_extend.c
+++ b/net/netfilter/nf_conntrack_extend.c
@@ -95,7 +95,7 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)
95 newlen = newoff + t->len; 95 newlen = newoff + t->len;
96 rcu_read_unlock(); 96 rcu_read_unlock();
97 97
98 new = krealloc(ct->ext, newlen, gfp); 98 new = __krealloc(ct->ext, newlen, gfp);
99 if (!new) 99 if (!new)
100 return NULL; 100 return NULL;
101 101
@@ -115,10 +115,10 @@ void *__nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp)
115 ct->ext = new; 115 ct->ext = new;
116 } 116 }
117 117
118 ct->ext->offset[id] = newoff; 118 new->offset[id] = newoff;
119 ct->ext->len = newlen; 119 new->len = newlen;
120 memset((void *)ct->ext + newoff, 0, newlen - newoff); 120 memset((void *)new + newoff, 0, newlen - newoff);
121 return (void *)ct->ext + newoff; 121 return (void *)new + newoff;
122} 122}
123EXPORT_SYMBOL(__nf_ct_ext_add); 123EXPORT_SYMBOL(__nf_ct_ext_add);
124 124
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index 04faa835be17..6b517b9dac5b 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -162,7 +162,7 @@ static void atm_tc_put(struct Qdisc *sch, unsigned long cl)
162 qdisc_destroy(flow->q); 162 qdisc_destroy(flow->q);
163 tcf_destroy_chain(&flow->filter_list); 163 tcf_destroy_chain(&flow->filter_list);
164 if (flow->sock) { 164 if (flow->sock) {
165 pr_debug("atm_tc_put: f_count %d\n", 165 pr_debug("atm_tc_put: f_count %ld\n",
166 file_count(flow->sock->file)); 166 file_count(flow->sock->file));
167 flow->vcc->pop = flow->old_pop; 167 flow->vcc->pop = flow->old_pop;
168 sockfd_put(flow->sock); 168 sockfd_put(flow->sock);
@@ -259,7 +259,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
259 sock = sockfd_lookup(fd, &error); 259 sock = sockfd_lookup(fd, &error);
260 if (!sock) 260 if (!sock)
261 return error; /* f_count++ */ 261 return error; /* f_count++ */
262 pr_debug("atm_tc_change: f_count %d\n", file_count(sock->file)); 262 pr_debug("atm_tc_change: f_count %ld\n", file_count(sock->file));
263 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) { 263 if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
264 error = -EPROTOTYPE; 264 error = -EPROTOTYPE;
265 goto err_out; 265 goto err_out;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 79bece16aede..dbb79adf8f3c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3910,7 +3910,7 @@ static int sctp_getsockopt_peeloff(struct sock *sk, int len, char __user *optval
3910 goto out; 3910 goto out;
3911 3911
3912 /* Map the socket to an unused fd that can be returned to the user. */ 3912 /* Map the socket to an unused fd that can be returned to the user. */
3913 retval = sock_map_fd(newsock); 3913 retval = sock_map_fd(newsock, 0);
3914 if (retval < 0) { 3914 if (retval < 0) {
3915 sock_release(newsock); 3915 sock_release(newsock);
3916 goto out; 3916 goto out;
diff --git a/net/socket.c b/net/socket.c
index 1ba57d888981..8ef8ba81b9e2 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -63,11 +63,13 @@
63#include <linux/file.h> 63#include <linux/file.h>
64#include <linux/net.h> 64#include <linux/net.h>
65#include <linux/interrupt.h> 65#include <linux/interrupt.h>
66#include <linux/thread_info.h>
66#include <linux/rcupdate.h> 67#include <linux/rcupdate.h>
67#include <linux/netdevice.h> 68#include <linux/netdevice.h>
68#include <linux/proc_fs.h> 69#include <linux/proc_fs.h>
69#include <linux/seq_file.h> 70#include <linux/seq_file.h>
70#include <linux/mutex.h> 71#include <linux/mutex.h>
72#include <linux/thread_info.h>
71#include <linux/wanrouter.h> 73#include <linux/wanrouter.h>
72#include <linux/if_bridge.h> 74#include <linux/if_bridge.h>
73#include <linux/if_frad.h> 75#include <linux/if_frad.h>
@@ -263,7 +265,7 @@ static void sock_destroy_inode(struct inode *inode)
263 container_of(inode, struct socket_alloc, vfs_inode)); 265 container_of(inode, struct socket_alloc, vfs_inode));
264} 266}
265 267
266static void init_once(struct kmem_cache *cachep, void *foo) 268static void init_once(void *foo)
267{ 269{
268 struct socket_alloc *ei = (struct socket_alloc *)foo; 270 struct socket_alloc *ei = (struct socket_alloc *)foo;
269 271
@@ -349,11 +351,11 @@ static struct dentry_operations sockfs_dentry_operations = {
349 * but we take care of internal coherence yet. 351 * but we take care of internal coherence yet.
350 */ 352 */
351 353
352static int sock_alloc_fd(struct file **filep) 354static int sock_alloc_fd(struct file **filep, int flags)
353{ 355{
354 int fd; 356 int fd;
355 357
356 fd = get_unused_fd(); 358 fd = get_unused_fd_flags(flags);
357 if (likely(fd >= 0)) { 359 if (likely(fd >= 0)) {
358 struct file *file = get_empty_filp(); 360 struct file *file = get_empty_filp();
359 361
@@ -367,7 +369,7 @@ static int sock_alloc_fd(struct file **filep)
367 return fd; 369 return fd;
368} 370}
369 371
370static int sock_attach_fd(struct socket *sock, struct file *file) 372static int sock_attach_fd(struct socket *sock, struct file *file, int flags)
371{ 373{
372 struct dentry *dentry; 374 struct dentry *dentry;
373 struct qstr name = { .name = "" }; 375 struct qstr name = { .name = "" };
@@ -389,20 +391,20 @@ static int sock_attach_fd(struct socket *sock, struct file *file)
389 init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE, 391 init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE,
390 &socket_file_ops); 392 &socket_file_ops);
391 SOCK_INODE(sock)->i_fop = &socket_file_ops; 393 SOCK_INODE(sock)->i_fop = &socket_file_ops;
392 file->f_flags = O_RDWR; 394 file->f_flags = O_RDWR | (flags & O_NONBLOCK);
393 file->f_pos = 0; 395 file->f_pos = 0;
394 file->private_data = sock; 396 file->private_data = sock;
395 397
396 return 0; 398 return 0;
397} 399}
398 400
399int sock_map_fd(struct socket *sock) 401int sock_map_fd(struct socket *sock, int flags)
400{ 402{
401 struct file *newfile; 403 struct file *newfile;
402 int fd = sock_alloc_fd(&newfile); 404 int fd = sock_alloc_fd(&newfile, flags);
403 405
404 if (likely(fd >= 0)) { 406 if (likely(fd >= 0)) {
405 int err = sock_attach_fd(sock, newfile); 407 int err = sock_attach_fd(sock, newfile, flags);
406 408
407 if (unlikely(err < 0)) { 409 if (unlikely(err < 0)) {
408 put_filp(newfile); 410 put_filp(newfile);
@@ -1218,12 +1220,27 @@ asmlinkage long sys_socket(int family, int type, int protocol)
1218{ 1220{
1219 int retval; 1221 int retval;
1220 struct socket *sock; 1222 struct socket *sock;
1223 int flags;
1224
1225 /* Check the SOCK_* constants for consistency. */
1226 BUILD_BUG_ON(SOCK_CLOEXEC != O_CLOEXEC);
1227 BUILD_BUG_ON((SOCK_MAX | SOCK_TYPE_MASK) != SOCK_TYPE_MASK);
1228 BUILD_BUG_ON(SOCK_CLOEXEC & SOCK_TYPE_MASK);
1229 BUILD_BUG_ON(SOCK_NONBLOCK & SOCK_TYPE_MASK);
1230
1231 flags = type & ~SOCK_TYPE_MASK;
1232 if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
1233 return -EINVAL;
1234 type &= SOCK_TYPE_MASK;
1235
1236 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
1237 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
1221 1238
1222 retval = sock_create(family, type, protocol, &sock); 1239 retval = sock_create(family, type, protocol, &sock);
1223 if (retval < 0) 1240 if (retval < 0)
1224 goto out; 1241 goto out;
1225 1242
1226 retval = sock_map_fd(sock); 1243 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
1227 if (retval < 0) 1244 if (retval < 0)
1228 goto out_release; 1245 goto out_release;
1229 1246
@@ -1246,6 +1263,15 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
1246 struct socket *sock1, *sock2; 1263 struct socket *sock1, *sock2;
1247 int fd1, fd2, err; 1264 int fd1, fd2, err;
1248 struct file *newfile1, *newfile2; 1265 struct file *newfile1, *newfile2;
1266 int flags;
1267
1268 flags = type & ~SOCK_TYPE_MASK;
1269 if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
1270 return -EINVAL;
1271 type &= SOCK_TYPE_MASK;
1272
1273 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
1274 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
1249 1275
1250 /* 1276 /*
1251 * Obtain the first socket and check if the underlying protocol 1277 * Obtain the first socket and check if the underlying protocol
@@ -1264,13 +1290,13 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
1264 if (err < 0) 1290 if (err < 0)
1265 goto out_release_both; 1291 goto out_release_both;
1266 1292
1267 fd1 = sock_alloc_fd(&newfile1); 1293 fd1 = sock_alloc_fd(&newfile1, flags & O_CLOEXEC);
1268 if (unlikely(fd1 < 0)) { 1294 if (unlikely(fd1 < 0)) {
1269 err = fd1; 1295 err = fd1;
1270 goto out_release_both; 1296 goto out_release_both;
1271 } 1297 }
1272 1298
1273 fd2 = sock_alloc_fd(&newfile2); 1299 fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC);
1274 if (unlikely(fd2 < 0)) { 1300 if (unlikely(fd2 < 0)) {
1275 err = fd2; 1301 err = fd2;
1276 put_filp(newfile1); 1302 put_filp(newfile1);
@@ -1278,12 +1304,12 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,
1278 goto out_release_both; 1304 goto out_release_both;
1279 } 1305 }
1280 1306
1281 err = sock_attach_fd(sock1, newfile1); 1307 err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK);
1282 if (unlikely(err < 0)) { 1308 if (unlikely(err < 0)) {
1283 goto out_fd2; 1309 goto out_fd2;
1284 } 1310 }
1285 1311
1286 err = sock_attach_fd(sock2, newfile2); 1312 err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK);
1287 if (unlikely(err < 0)) { 1313 if (unlikely(err < 0)) {
1288 fput(newfile1); 1314 fput(newfile1);
1289 goto out_fd1; 1315 goto out_fd1;
@@ -1401,14 +1427,20 @@ asmlinkage long sys_listen(int fd, int backlog)
1401 * clean when we restucture accept also. 1427 * clean when we restucture accept also.
1402 */ 1428 */
1403 1429
1404asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, 1430long do_accept(int fd, struct sockaddr __user *upeer_sockaddr,
1405 int __user *upeer_addrlen) 1431 int __user *upeer_addrlen, int flags)
1406{ 1432{
1407 struct socket *sock, *newsock; 1433 struct socket *sock, *newsock;
1408 struct file *newfile; 1434 struct file *newfile;
1409 int err, len, newfd, fput_needed; 1435 int err, len, newfd, fput_needed;
1410 struct sockaddr_storage address; 1436 struct sockaddr_storage address;
1411 1437
1438 if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
1439 return -EINVAL;
1440
1441 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
1442 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
1443
1412 sock = sockfd_lookup_light(fd, &err, &fput_needed); 1444 sock = sockfd_lookup_light(fd, &err, &fput_needed);
1413 if (!sock) 1445 if (!sock)
1414 goto out; 1446 goto out;
@@ -1426,14 +1458,14 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
1426 */ 1458 */
1427 __module_get(newsock->ops->owner); 1459 __module_get(newsock->ops->owner);
1428 1460
1429 newfd = sock_alloc_fd(&newfile); 1461 newfd = sock_alloc_fd(&newfile, flags & O_CLOEXEC);
1430 if (unlikely(newfd < 0)) { 1462 if (unlikely(newfd < 0)) {
1431 err = newfd; 1463 err = newfd;
1432 sock_release(newsock); 1464 sock_release(newsock);
1433 goto out_put; 1465 goto out_put;
1434 } 1466 }
1435 1467
1436 err = sock_attach_fd(newsock, newfile); 1468 err = sock_attach_fd(newsock, newfile, flags & O_NONBLOCK);
1437 if (err < 0) 1469 if (err < 0)
1438 goto out_fd_simple; 1470 goto out_fd_simple;
1439 1471
@@ -1479,6 +1511,66 @@ out_fd:
1479 goto out_put; 1511 goto out_put;
1480} 1512}
1481 1513
1514#ifdef HAVE_SET_RESTORE_SIGMASK
1515asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
1516 int __user *upeer_addrlen,
1517 const sigset_t __user *sigmask,
1518 size_t sigsetsize, int flags)
1519{
1520 sigset_t ksigmask, sigsaved;
1521 int ret;
1522
1523 if (sigmask) {
1524 /* XXX: Don't preclude handling different sized sigset_t's. */
1525 if (sigsetsize != sizeof(sigset_t))
1526 return -EINVAL;
1527 if (copy_from_user(&ksigmask, sigmask, sizeof(ksigmask)))
1528 return -EFAULT;
1529
1530 sigdelsetmask(&ksigmask, sigmask(SIGKILL)|sigmask(SIGSTOP));
1531 sigprocmask(SIG_SETMASK, &ksigmask, &sigsaved);
1532 }
1533
1534 ret = do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
1535
1536 if (ret < 0 && signal_pending(current)) {
1537 /*
1538 * Don't restore the signal mask yet. Let do_signal() deliver
1539 * the signal on the way back to userspace, before the signal
1540 * mask is restored.
1541 */
1542 if (sigmask) {
1543 memcpy(&current->saved_sigmask, &sigsaved,
1544 sizeof(sigsaved));
1545 set_restore_sigmask();
1546 }
1547 } else if (sigmask)
1548 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
1549
1550 return ret;
1551}
1552#else
1553asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr,
1554 int __user *upeer_addrlen,
1555 const sigset_t __user *sigmask,
1556 size_t sigsetsize, int flags)
1557{
1558 /* The platform does not support restoring the signal mask in the
1559 * return path. So we do not allow using paccept() with a signal
1560 * mask. */
1561 if (sigmask)
1562 return -EINVAL;
1563
1564 return do_accept(fd, upeer_sockaddr, upeer_addrlen, flags);
1565}
1566#endif
1567
1568asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr,
1569 int __user *upeer_addrlen)
1570{
1571 return do_accept(fd, upeer_sockaddr, upeer_addrlen, 0);
1572}
1573
1482/* 1574/*
1483 * Attempt to connect to a socket with the server address. The address 1575 * Attempt to connect to a socket with the server address. The address
1484 * is in user space so we verify it is OK and move it to kernel space. 1576 * is in user space so we verify it is OK and move it to kernel space.
@@ -1999,10 +2091,11 @@ out:
1999 2091
2000/* Argument list sizes for sys_socketcall */ 2092/* Argument list sizes for sys_socketcall */
2001#define AL(x) ((x) * sizeof(unsigned long)) 2093#define AL(x) ((x) * sizeof(unsigned long))
2002static const unsigned char nargs[18]={ 2094static const unsigned char nargs[19]={
2003 AL(0),AL(3),AL(3),AL(3),AL(2),AL(3), 2095 AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
2004 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6), 2096 AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
2005 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3) 2097 AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
2098 AL(6)
2006}; 2099};
2007 2100
2008#undef AL 2101#undef AL
@@ -2021,7 +2114,7 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2021 unsigned long a0, a1; 2114 unsigned long a0, a1;
2022 int err; 2115 int err;
2023 2116
2024 if (call < 1 || call > SYS_RECVMSG) 2117 if (call < 1 || call > SYS_PACCEPT)
2025 return -EINVAL; 2118 return -EINVAL;
2026 2119
2027 /* copy_from_user should be SMP safe. */ 2120 /* copy_from_user should be SMP safe. */
@@ -2050,8 +2143,8 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2050 break; 2143 break;
2051 case SYS_ACCEPT: 2144 case SYS_ACCEPT:
2052 err = 2145 err =
2053 sys_accept(a0, (struct sockaddr __user *)a1, 2146 do_accept(a0, (struct sockaddr __user *)a1,
2054 (int __user *)a[2]); 2147 (int __user *)a[2], 0);
2055 break; 2148 break;
2056 case SYS_GETSOCKNAME: 2149 case SYS_GETSOCKNAME:
2057 err = 2150 err =
@@ -2098,6 +2191,13 @@ asmlinkage long sys_socketcall(int call, unsigned long __user *args)
2098 case SYS_RECVMSG: 2191 case SYS_RECVMSG:
2099 err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]); 2192 err = sys_recvmsg(a0, (struct msghdr __user *)a1, a[2]);
2100 break; 2193 break;
2194 case SYS_PACCEPT:
2195 err =
2196 sys_paccept(a0, (struct sockaddr __user *)a1,
2197 (int __user *)a[2],
2198 (const sigset_t __user *) a[3],
2199 a[4], a[5]);
2200 break;
2101 default: 2201 default:
2102 err = -EINVAL; 2202 err = -EINVAL;
2103 break; 2203 break;
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 5a9b0e7828cd..23a2b8f6dc49 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -897,7 +897,7 @@ static struct file_system_type rpc_pipe_fs_type = {
897}; 897};
898 898
899static void 899static void
900init_once(struct kmem_cache * cachep, void *foo) 900init_once(void *foo)
901{ 901{
902 struct rpc_inode *rpci = (struct rpc_inode *) foo; 902 struct rpc_inode *rpci = (struct rpc_inode *) foo;
903 903
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 5a32cb7c4bb4..835d27413083 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -310,7 +310,8 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)
310 switch (m->mode) { 310 switch (m->mode) {
311 case SVC_POOL_PERCPU: 311 case SVC_POOL_PERCPU:
312 { 312 {
313 set_cpus_allowed_ptr(task, &cpumask_of_cpu(node)); 313 cpumask_of_cpu_ptr(cpumask, node);
314 set_cpus_allowed_ptr(task, cpumask);
314 break; 315 break;
315 } 316 }
316 case SVC_POOL_PERNODE: 317 case SVC_POOL_PERNODE:
diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
index a19b22b452a3..84d328329d98 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
@@ -169,7 +169,8 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
169 (void *) 169 (void *)
170 vec->sge[xdr_sge_no].iov_base + sge_off, 170 vec->sge[xdr_sge_no].iov_base + sge_off,
171 sge_bytes, DMA_TO_DEVICE); 171 sge_bytes, DMA_TO_DEVICE);
172 if (dma_mapping_error(sge[sge_no].addr)) 172 if (dma_mapping_error(xprt->sc_cm_id->device->dma_device,
173 sge[sge_no].addr))
173 goto err; 174 goto err;
174 sge_off = 0; 175 sge_off = 0;
175 sge_no++; 176 sge_no++;
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index 007c1a6708ee..972201cd5fa7 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -29,23 +29,35 @@
29#include <linux/if_tr.h> 29#include <linux/if_tr.h>
30#endif 30#endif
31 31
32static struct list_head * 32static struct ctl_table_set *
33net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces) 33net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces)
34{ 34{
35 return &namespaces->net_ns->sysctl_table_headers; 35 return &namespaces->net_ns->sysctls;
36} 36}
37 37
38static struct ctl_table_root net_sysctl_root = { 38static int is_seen(struct ctl_table_set *set)
39 .lookup = net_ctl_header_lookup, 39{
40}; 40 return &current->nsproxy->net_ns->sysctls == set;
41}
41 42
42static LIST_HEAD(net_sysctl_ro_tables); 43/* Return standard mode bits for table entry. */
43static struct list_head *net_ctl_ro_header_lookup(struct ctl_table_root *root, 44static int net_ctl_permissions(struct ctl_table_root *root,
44 struct nsproxy *namespaces) 45 struct nsproxy *nsproxy,
46 struct ctl_table *table)
45{ 47{
46 return &net_sysctl_ro_tables; 48 /* Allow network administrator to have same access as root. */
49 if (capable(CAP_NET_ADMIN)) {
50 int mode = (table->mode >> 6) & 7;
51 return (mode << 6) | (mode << 3) | mode;
52 }
53 return table->mode;
47} 54}
48 55
56static struct ctl_table_root net_sysctl_root = {
57 .lookup = net_ctl_header_lookup,
58 .permissions = net_ctl_permissions,
59};
60
49static int net_ctl_ro_header_perms(struct ctl_table_root *root, 61static int net_ctl_ro_header_perms(struct ctl_table_root *root,
50 struct nsproxy *namespaces, struct ctl_table *table) 62 struct nsproxy *namespaces, struct ctl_table *table)
51{ 63{
@@ -56,19 +68,20 @@ static int net_ctl_ro_header_perms(struct ctl_table_root *root,
56} 68}
57 69
58static struct ctl_table_root net_sysctl_ro_root = { 70static struct ctl_table_root net_sysctl_ro_root = {
59 .lookup = net_ctl_ro_header_lookup,
60 .permissions = net_ctl_ro_header_perms, 71 .permissions = net_ctl_ro_header_perms,
61}; 72};
62 73
63static int sysctl_net_init(struct net *net) 74static int sysctl_net_init(struct net *net)
64{ 75{
65 INIT_LIST_HEAD(&net->sysctl_table_headers); 76 setup_sysctl_set(&net->sysctls,
77 &net_sysctl_ro_root.default_set,
78 is_seen);
66 return 0; 79 return 0;
67} 80}
68 81
69static void sysctl_net_exit(struct net *net) 82static void sysctl_net_exit(struct net *net)
70{ 83{
71 WARN_ON(!list_empty(&net->sysctl_table_headers)); 84 WARN_ON(!list_empty(&net->sysctls.list));
72 return; 85 return;
73} 86}
74 87
@@ -84,6 +97,7 @@ static __init int sysctl_init(void)
84 if (ret) 97 if (ret)
85 goto out; 98 goto out;
86 register_sysctl_root(&net_sysctl_root); 99 register_sysctl_root(&net_sysctl_root);
100 setup_sysctl_set(&net_sysctl_ro_root.default_set, NULL, NULL);
87 register_sysctl_root(&net_sysctl_ro_root); 101 register_sysctl_root(&net_sysctl_ro_root);
88out: 102out:
89 return ret; 103 return ret;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 24eb214581d5..015606b54d9b 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -603,7 +603,7 @@ static struct sock * unix_create1(struct net *net, struct socket *sock)
603 u->dentry = NULL; 603 u->dentry = NULL;
604 u->mnt = NULL; 604 u->mnt = NULL;
605 spin_lock_init(&u->lock); 605 spin_lock_init(&u->lock);
606 atomic_set(&u->inflight, 0); 606 atomic_long_set(&u->inflight, 0);
607 INIT_LIST_HEAD(&u->link); 607 INIT_LIST_HEAD(&u->link);
608 mutex_init(&u->readlock); /* single task reading lock */ 608 mutex_init(&u->readlock); /* single task reading lock */
609 init_waitqueue_head(&u->peer_wait); 609 init_waitqueue_head(&u->peer_wait);
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index ebdff3d877a1..2a27b84f740b 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -127,7 +127,7 @@ void unix_inflight(struct file *fp)
127 if(s) { 127 if(s) {
128 struct unix_sock *u = unix_sk(s); 128 struct unix_sock *u = unix_sk(s);
129 spin_lock(&unix_gc_lock); 129 spin_lock(&unix_gc_lock);
130 if (atomic_inc_return(&u->inflight) == 1) { 130 if (atomic_long_inc_return(&u->inflight) == 1) {
131 BUG_ON(!list_empty(&u->link)); 131 BUG_ON(!list_empty(&u->link));
132 list_add_tail(&u->link, &gc_inflight_list); 132 list_add_tail(&u->link, &gc_inflight_list);
133 } else { 133 } else {
@@ -145,7 +145,7 @@ void unix_notinflight(struct file *fp)
145 struct unix_sock *u = unix_sk(s); 145 struct unix_sock *u = unix_sk(s);
146 spin_lock(&unix_gc_lock); 146 spin_lock(&unix_gc_lock);
147 BUG_ON(list_empty(&u->link)); 147 BUG_ON(list_empty(&u->link));
148 if (atomic_dec_and_test(&u->inflight)) 148 if (atomic_long_dec_and_test(&u->inflight))
149 list_del_init(&u->link); 149 list_del_init(&u->link);
150 unix_tot_inflight--; 150 unix_tot_inflight--;
151 spin_unlock(&unix_gc_lock); 151 spin_unlock(&unix_gc_lock);
@@ -237,17 +237,17 @@ static void scan_children(struct sock *x, void (*func)(struct unix_sock *),
237 237
238static void dec_inflight(struct unix_sock *usk) 238static void dec_inflight(struct unix_sock *usk)
239{ 239{
240 atomic_dec(&usk->inflight); 240 atomic_long_dec(&usk->inflight);
241} 241}
242 242
243static void inc_inflight(struct unix_sock *usk) 243static void inc_inflight(struct unix_sock *usk)
244{ 244{
245 atomic_inc(&usk->inflight); 245 atomic_long_inc(&usk->inflight);
246} 246}
247 247
248static void inc_inflight_move_tail(struct unix_sock *u) 248static void inc_inflight_move_tail(struct unix_sock *u)
249{ 249{
250 atomic_inc(&u->inflight); 250 atomic_long_inc(&u->inflight);
251 /* 251 /*
252 * If this is still a candidate, move it to the end of the 252 * If this is still a candidate, move it to the end of the
253 * list, so that it's checked even if it was already passed 253 * list, so that it's checked even if it was already passed
@@ -288,11 +288,11 @@ void unix_gc(void)
288 * before the detach without atomicity guarantees. 288 * before the detach without atomicity guarantees.
289 */ 289 */
290 list_for_each_entry_safe(u, next, &gc_inflight_list, link) { 290 list_for_each_entry_safe(u, next, &gc_inflight_list, link) {
291 int total_refs; 291 long total_refs;
292 int inflight_refs; 292 long inflight_refs;
293 293
294 total_refs = file_count(u->sk.sk_socket->file); 294 total_refs = file_count(u->sk.sk_socket->file);
295 inflight_refs = atomic_read(&u->inflight); 295 inflight_refs = atomic_long_read(&u->inflight);
296 296
297 BUG_ON(inflight_refs < 1); 297 BUG_ON(inflight_refs < 1);
298 BUG_ON(total_refs < inflight_refs); 298 BUG_ON(total_refs < inflight_refs);
@@ -324,7 +324,7 @@ void unix_gc(void)
324 /* Move cursor to after the current position. */ 324 /* Move cursor to after the current position. */
325 list_move(&cursor, &u->link); 325 list_move(&cursor, &u->link);
326 326
327 if (atomic_read(&u->inflight) > 0) { 327 if (atomic_long_read(&u->inflight) > 0) {
328 list_move_tail(&u->link, &gc_inflight_list); 328 list_move_tail(&u->link, &gc_inflight_list);
329 u->gc_candidate = 0; 329 u->gc_candidate = 0;
330 scan_children(&u->sk, inc_inflight_move_tail, NULL); 330 scan_children(&u->sk, inc_inflight_move_tail, NULL);