aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbingtian.ly@taobao.com <bingtian.ly@taobao.com>2013-01-23 20:35:28 +0000
committerStefan Bader <stefan.bader@canonical.com>2015-05-29 11:54:16 +0200
commit19d110d6af4aec76e1d18780808a5737c5433435 (patch)
tree6b86350aae2108d01887604af96920247160d5d9
parentd9df18a5c5eff6d9eaedcece7bb4c60106ae1c77 (diff)
downloadlinux-2.6.32.y-drm33.z-19d110d6af4aec76e1d18780808a5737c5433435.tar.gz
net: avoid to hang up on sending due to sysctl configuration overflow.
commit cdda88912d62f9603d27433338a18be83ef23ac1 upstream. 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> [bwh: Backported to 3.2: - Adjust context - Delete now-unused 'zero' variable] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> (cherry picked from commit 98eee187cdee2807bd80e6c02180c5c2abae6453) [wt: backported to 2.6.32: set strategy to sysctl_intvec where relevant] Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
-rw-r--r--net/core/sysctl_net_core.c18
-rw-r--r--net/ipv4/sysctl_net_ipv4.c13
2 files changed, 23 insertions, 8 deletions
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index e6bf72ce2fa781..a6003283ea0b06 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -17,6 +17,8 @@
static int zero = 0;
static int ushort_max = 65535;
+static int one = 1;
+
static struct ctl_table net_core_table[] = {
#ifdef CONFIG_NET
{
@@ -25,7 +27,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_wmem_max,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dointvec
+ .proc_handler = proc_dointvec_minmax,
+ .strategy = sysctl_intvec,
+ .extra1 = &one,
},
{
.ctl_name = NET_CORE_RMEM_MAX,
@@ -33,7 +37,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_rmem_max,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dointvec
+ .proc_handler = proc_dointvec_minmax,
+ .strategy = sysctl_intvec,
+ .extra1 = &one,
},
{
.ctl_name = NET_CORE_WMEM_DEFAULT,
@@ -41,7 +47,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_wmem_default,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dointvec
+ .proc_handler = proc_dointvec_minmax,
+ .strategy = sysctl_intvec,
+ .extra1 = &one,
},
{
.ctl_name = NET_CORE_RMEM_DEFAULT,
@@ -49,7 +57,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_rmem_default,
.maxlen = sizeof(int),
.mode = 0644,
- .proc_handler = proc_dointvec
+ .proc_handler = proc_dointvec_minmax,
+ .strategy = sysctl_intvec,
+ .extra1 = &one,
},
{
.ctl_name = NET_CORE_DEV_WEIGHT,
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index d957371a80d0ad..d1a8883297cf7d 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -22,6 +22,7 @@
#include <net/inet_frag.h>
static int zero;
+static int one = 1;
static int tcp_retr1_max = 255;
static int tcp_syn_retries_min = 1;
static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
@@ -521,7 +522,9 @@ static struct ctl_table ipv4_table[] = {
.data = &sysctl_tcp_wmem,
.maxlen = sizeof(sysctl_tcp_wmem),
.mode = 0644,
- .proc_handler = proc_dointvec
+ .proc_handler = proc_dointvec_minmax,
+ .strategy = sysctl_intvec,
+ .extra1 = &one,
},
{
.ctl_name = NET_TCP_RMEM,
@@ -529,7 +532,9 @@ static struct ctl_table ipv4_table[] = {
.data = &sysctl_tcp_rmem,
.maxlen = sizeof(sysctl_tcp_rmem),
.mode = 0644,
- .proc_handler = proc_dointvec
+ .proc_handler = proc_dointvec_minmax,
+ .strategy = sysctl_intvec,
+ .extra1 = &one,
},
{
.ctl_name = NET_TCP_APP_WIN,
@@ -735,7 +740,7 @@ static struct ctl_table ipv4_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
- .extra1 = &zero
+ .extra1 = &one
},
{
.ctl_name = CTL_UNNUMBERED,
@@ -745,7 +750,7 @@ static struct ctl_table ipv4_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
- .extra1 = &zero
+ .extra1 = &one
},
{ .ctl_name = 0 }
};