Commit 0f8a4ca1 authored by bingtian.ly@taobao.com's avatar bingtian.ly@taobao.com Committed by Willy Tarreau

net: avoid to hang up on sending due to sysctl configuration overflow.

commit cdda8891 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: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarLi Yu <raise.sail@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
[bwh: Backported to 3.2:
 - Adjust context
 - Delete now-unused 'zero' variable]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
(cherry picked from commit 98eee187)
[wt: backported to 2.6.32: set strategy to sysctl_intvec where relevant]
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 65f26669
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
static int zero = 0; static int zero = 0;
static int ushort_max = 65535; static int ushort_max = 65535;
static int one = 1;
static struct ctl_table net_core_table[] = { static struct ctl_table net_core_table[] = {
#ifdef CONFIG_NET #ifdef CONFIG_NET
{ {
...@@ -25,7 +27,9 @@ static struct ctl_table net_core_table[] = { ...@@ -25,7 +27,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_wmem_max, .data = &sysctl_wmem_max,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
.extra1 = &one,
}, },
{ {
.ctl_name = NET_CORE_RMEM_MAX, .ctl_name = NET_CORE_RMEM_MAX,
...@@ -33,7 +37,9 @@ static struct ctl_table net_core_table[] = { ...@@ -33,7 +37,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_rmem_max, .data = &sysctl_rmem_max,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
.extra1 = &one,
}, },
{ {
.ctl_name = NET_CORE_WMEM_DEFAULT, .ctl_name = NET_CORE_WMEM_DEFAULT,
...@@ -41,7 +47,9 @@ static struct ctl_table net_core_table[] = { ...@@ -41,7 +47,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_wmem_default, .data = &sysctl_wmem_default,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
.extra1 = &one,
}, },
{ {
.ctl_name = NET_CORE_RMEM_DEFAULT, .ctl_name = NET_CORE_RMEM_DEFAULT,
...@@ -49,7 +57,9 @@ static struct ctl_table net_core_table[] = { ...@@ -49,7 +57,9 @@ static struct ctl_table net_core_table[] = {
.data = &sysctl_rmem_default, .data = &sysctl_rmem_default,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
.extra1 = &one,
}, },
{ {
.ctl_name = NET_CORE_DEV_WEIGHT, .ctl_name = NET_CORE_DEV_WEIGHT,
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <net/inet_frag.h> #include <net/inet_frag.h>
static int zero; static int zero;
static int one = 1;
static int tcp_retr1_max = 255; static int tcp_retr1_max = 255;
static int tcp_syn_retries_min = 1; static int tcp_syn_retries_min = 1;
static int tcp_syn_retries_max = MAX_TCP_SYNCNT; static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
...@@ -521,7 +522,9 @@ static struct ctl_table ipv4_table[] = { ...@@ -521,7 +522,9 @@ static struct ctl_table ipv4_table[] = {
.data = &sysctl_tcp_wmem, .data = &sysctl_tcp_wmem,
.maxlen = sizeof(sysctl_tcp_wmem), .maxlen = sizeof(sysctl_tcp_wmem),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
.extra1 = &one,
}, },
{ {
.ctl_name = NET_TCP_RMEM, .ctl_name = NET_TCP_RMEM,
...@@ -529,7 +532,9 @@ static struct ctl_table ipv4_table[] = { ...@@ -529,7 +532,9 @@ static struct ctl_table ipv4_table[] = {
.data = &sysctl_tcp_rmem, .data = &sysctl_tcp_rmem,
.maxlen = sizeof(sysctl_tcp_rmem), .maxlen = sizeof(sysctl_tcp_rmem),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec,
.extra1 = &one,
}, },
{ {
.ctl_name = NET_TCP_APP_WIN, .ctl_name = NET_TCP_APP_WIN,
...@@ -735,7 +740,7 @@ static struct ctl_table ipv4_table[] = { ...@@ -735,7 +740,7 @@ static struct ctl_table ipv4_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec, .strategy = sysctl_intvec,
.extra1 = &zero .extra1 = &one
}, },
{ {
.ctl_name = CTL_UNNUMBERED, .ctl_name = CTL_UNNUMBERED,
...@@ -745,7 +750,7 @@ static struct ctl_table ipv4_table[] = { ...@@ -745,7 +750,7 @@ static struct ctl_table ipv4_table[] = {
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.strategy = sysctl_intvec, .strategy = sysctl_intvec,
.extra1 = &zero .extra1 = &one
}, },
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment