diff options
author | bingtian.ly@taobao.com <bingtian.ly@taobao.com> | 2013-01-23 15:35:28 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-28 23:15:27 -0500 |
commit | cdda88912d62f9603d27433338a18be83ef23ac1 (patch) | |
tree | 5798502c9546bd3e8d20e2ac2d1ef01a8032b115 | |
parent | f7b5d1b9bd16e3ec71696abb204a8cfddd93aa62 (diff) |
net: avoid to hang up on sending due to sysctl configuration overflow.
I found if we write a larger than 4GB value to some sysctl
variables, the sending syscall will hang up forever, because these
variables are 32 bits, such large values make them overflow to 0 or
negative.
This patch try to fix overflow or prevent from zero value setup
of below sysctl variables:
net.core.wmem_default
net.core.rmem_default
net.core.rmem_max
net.core.wmem_max
net.ipv4.udp_rmem_min
net.ipv4.udp_wmem_min
net.ipv4.tcp_wmem
net.ipv4.tcp_rmem
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Li Yu <raise.sail@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/sysctl_net_core.c | 14 | ||||
-rw-r--r-- | net/ipv4/sysctl_net_ipv4.c | 11 |
2 files changed, 17 insertions, 8 deletions
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index d1b08045a9df..cfdb46ab3a7f 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <net/sock.h> | 20 | #include <net/sock.h> |
21 | #include <net/net_ratelimit.h> | 21 | #include <net/net_ratelimit.h> |
22 | 22 | ||
23 | static int one = 1; | ||
24 | |||
23 | #ifdef CONFIG_RPS | 25 | #ifdef CONFIG_RPS |
24 | static int rps_sock_flow_sysctl(ctl_table *table, int write, | 26 | static int rps_sock_flow_sysctl(ctl_table *table, int write, |
25 | void __user *buffer, size_t *lenp, loff_t *ppos) | 27 | void __user *buffer, size_t *lenp, loff_t *ppos) |
@@ -92,28 +94,32 @@ static struct ctl_table net_core_table[] = { | |||
92 | .data = &sysctl_wmem_max, | 94 | .data = &sysctl_wmem_max, |
93 | .maxlen = sizeof(int), | 95 | .maxlen = sizeof(int), |
94 | .mode = 0644, | 96 | .mode = 0644, |
95 | .proc_handler = proc_dointvec | 97 | .proc_handler = proc_dointvec_minmax, |
98 | .extra1 = &one, | ||
96 | }, | 99 | }, |
97 | { | 100 | { |
98 | .procname = "rmem_max", | 101 | .procname = "rmem_max", |
99 | .data = &sysctl_rmem_max, | 102 | .data = &sysctl_rmem_max, |
100 | .maxlen = sizeof(int), | 103 | .maxlen = sizeof(int), |
101 | .mode = 0644, | 104 | .mode = 0644, |
102 | .proc_handler = proc_dointvec | 105 | .proc_handler = proc_dointvec_minmax, |
106 | .extra1 = &one, | ||
103 | }, | 107 | }, |
104 | { | 108 | { |
105 | .procname = "wmem_default", | 109 | .procname = "wmem_default", |
106 | .data = &sysctl_wmem_default, | 110 | .data = &sysctl_wmem_default, |
107 | .maxlen = sizeof(int), | 111 | .maxlen = sizeof(int), |
108 | .mode = 0644, | 112 | .mode = 0644, |
109 | .proc_handler = proc_dointvec | 113 | .proc_handler = proc_dointvec_minmax, |
114 | .extra1 = &one, | ||
110 | }, | 115 | }, |
111 | { | 116 | { |
112 | .procname = "rmem_default", | 117 | .procname = "rmem_default", |
113 | .data = &sysctl_rmem_default, | 118 | .data = &sysctl_rmem_default, |
114 | .maxlen = sizeof(int), | 119 | .maxlen = sizeof(int), |
115 | .mode = 0644, | 120 | .mode = 0644, |
116 | .proc_handler = proc_dointvec | 121 | .proc_handler = proc_dointvec_minmax, |
122 | .extra1 = &one, | ||
117 | }, | 123 | }, |
118 | { | 124 | { |
119 | .procname = "dev_weight", | 125 | .procname = "dev_weight", |
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index a25e1d286b99..2622707602d1 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <net/tcp_memcontrol.h> | 27 | #include <net/tcp_memcontrol.h> |
28 | 28 | ||
29 | static int zero; | 29 | static int zero; |
30 | static int one = 1; | ||
30 | static int two = 2; | 31 | static int two = 2; |
31 | static int tcp_retr1_max = 255; | 32 | static int tcp_retr1_max = 255; |
32 | static int ip_local_port_range_min[] = { 1, 1 }; | 33 | static int ip_local_port_range_min[] = { 1, 1 }; |
@@ -549,14 +550,16 @@ static struct ctl_table ipv4_table[] = { | |||
549 | .data = &sysctl_tcp_wmem, | 550 | .data = &sysctl_tcp_wmem, |
550 | .maxlen = sizeof(sysctl_tcp_wmem), | 551 | .maxlen = sizeof(sysctl_tcp_wmem), |
551 | .mode = 0644, | 552 | .mode = 0644, |
552 | .proc_handler = proc_dointvec | 553 | .proc_handler = proc_dointvec_minmax, |
554 | .extra1 = &one, | ||
553 | }, | 555 | }, |
554 | { | 556 | { |
555 | .procname = "tcp_rmem", | 557 | .procname = "tcp_rmem", |
556 | .data = &sysctl_tcp_rmem, | 558 | .data = &sysctl_tcp_rmem, |
557 | .maxlen = sizeof(sysctl_tcp_rmem), | 559 | .maxlen = sizeof(sysctl_tcp_rmem), |
558 | .mode = 0644, | 560 | .mode = 0644, |
559 | .proc_handler = proc_dointvec | 561 | .proc_handler = proc_dointvec_minmax, |
562 | .extra1 = &one, | ||
560 | }, | 563 | }, |
561 | { | 564 | { |
562 | .procname = "tcp_app_win", | 565 | .procname = "tcp_app_win", |
@@ -779,7 +782,7 @@ static struct ctl_table ipv4_table[] = { | |||
779 | .maxlen = sizeof(sysctl_udp_rmem_min), | 782 | .maxlen = sizeof(sysctl_udp_rmem_min), |
780 | .mode = 0644, | 783 | .mode = 0644, |
781 | .proc_handler = proc_dointvec_minmax, | 784 | .proc_handler = proc_dointvec_minmax, |
782 | .extra1 = &zero | 785 | .extra1 = &one |
783 | }, | 786 | }, |
784 | { | 787 | { |
785 | .procname = "udp_wmem_min", | 788 | .procname = "udp_wmem_min", |
@@ -787,7 +790,7 @@ static struct ctl_table ipv4_table[] = { | |||
787 | .maxlen = sizeof(sysctl_udp_wmem_min), | 790 | .maxlen = sizeof(sysctl_udp_wmem_min), |
788 | .mode = 0644, | 791 | .mode = 0644, |
789 | .proc_handler = proc_dointvec_minmax, | 792 | .proc_handler = proc_dointvec_minmax, |
790 | .extra1 = &zero | 793 | .extra1 = &one |
791 | }, | 794 | }, |
792 | { } | 795 | { } |
793 | }; | 796 | }; |