diff options
author | Xi Wang <xi.wang@gmail.com> | 2011-12-16 12:44:15 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-06 14:14:08 -0800 |
commit | f6e4c89e089ae671a677242edb9e8b08c369c415 (patch) | |
tree | 8fc6a469a63235c7a4bf389833962eae9f8302ec /net/sctp/sysctl.c | |
parent | 01d6bbab3834409c220083f25810be9f1a553054 (diff) | |
download | kernel_samsung_espresso10-f6e4c89e089ae671a677242edb9e8b08c369c415.zip kernel_samsung_espresso10-f6e4c89e089ae671a677242edb9e8b08c369c415.tar.gz kernel_samsung_espresso10-f6e4c89e089ae671a677242edb9e8b08c369c415.tar.bz2 |
sctp: fix incorrect overflow check on autoclose
[ Upstream commit 2692ba61a82203404abd7dd2a027bda962861f74 ]
Commit 8ffd3208 voids the previous patches f6778aab and 810c0719 for
limiting the autoclose value. If userspace passes in -1 on 32-bit
platform, the overflow check didn't work and autoclose would be set
to 0xffffffff.
This patch defines a max_autoclose (in seconds) for limiting the value
and exposes it through sysctl, with the following intentions.
1) Avoid overflowing autoclose * HZ.
2) Keep the default autoclose bound consistent across 32- and 64-bit
platforms (INT_MAX / HZ in this patch).
3) Keep the autoclose value consistent between setsockopt() and
getsockopt() calls.
Suggested-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'net/sctp/sysctl.c')
-rw-r--r-- | net/sctp/sysctl.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index 50cb57f..6752f48 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -53,6 +53,10 @@ static int sack_timer_min = 1; static int sack_timer_max = 500; static int addr_scope_max = 3; /* check sctp_scope_policy_t in include/net/sctp/constants.h for max entries */ static int rwnd_scale_max = 16; +static unsigned long max_autoclose_min = 0; +static unsigned long max_autoclose_max = + (MAX_SCHEDULE_TIMEOUT / HZ > UINT_MAX) + ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ; extern long sysctl_sctp_mem[3]; extern int sysctl_sctp_rmem[3]; @@ -251,6 +255,15 @@ static ctl_table sctp_table[] = { .extra1 = &one, .extra2 = &rwnd_scale_max, }, + { + .procname = "max_autoclose", + .data = &sctp_max_autoclose, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = &proc_doulongvec_minmax, + .extra1 = &max_autoclose_min, + .extra2 = &max_autoclose_max, + }, { /* sentinel */ } }; |