mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Xi Wang <xi.wang@gmail.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [66/75] sctp: fix incorrect overflow check on autoclose
Date: Tue, 03 Jan 2012 14:33:39 -0800	[thread overview]
Message-ID: <20120103223326.624073171@clark.kroah.org> (raw)
In-Reply-To: <20120103223332.GA4112@kroah.com>

3.1-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Xi Wang <xi.wang@gmail.com>

[ 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>
---
 include/net/sctp/structs.h |    4 ++++
 net/sctp/associola.c       |    2 +-
 net/sctp/protocol.c        |    3 +++
 net/sctp/socket.c          |    2 --
 net/sctp/sysctl.c          |   13 +++++++++++++
 5 files changed, 21 insertions(+), 3 deletions(-)

--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -241,6 +241,9 @@ extern struct sctp_globals {
 	 * bits is an indicator of when to send and window update SACK.
 	 */
 	int rwnd_update_shift;
+
+	/* Threshold for autoclose timeout, in seconds. */
+	unsigned long max_autoclose;
 } sctp_globals;
 
 #define sctp_rto_initial		(sctp_globals.rto_initial)
@@ -281,6 +284,7 @@ extern struct sctp_globals {
 #define sctp_auth_enable		(sctp_globals.auth_enable)
 #define sctp_checksum_disable		(sctp_globals.checksum_disable)
 #define sctp_rwnd_upd_shift		(sctp_globals.rwnd_update_shift)
+#define sctp_max_autoclose		(sctp_globals.max_autoclose)
 
 /* SCTP Socket type: UDP or TCP style. */
 typedef enum {
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -173,7 +173,7 @@ static struct sctp_association *sctp_ass
 	asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0;
 	asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
 	asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
-		(unsigned long)sp->autoclose * HZ;
+		min_t(unsigned long, sp->autoclose, sctp_max_autoclose) * HZ;
 
 	/* Initializes the timers */
 	for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -1285,6 +1285,9 @@ SCTP_STATIC __init int sctp_init(void)
 	sctp_max_instreams    		= SCTP_DEFAULT_INSTREAMS;
 	sctp_max_outstreams   		= SCTP_DEFAULT_OUTSTREAMS;
 
+	/* Initialize maximum autoclose timeout. */
+	sctp_max_autoclose		= INT_MAX / HZ;
+
 	/* Initialize handle used for association ids. */
 	idr_init(&sctp_assocs_id);
 
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2199,8 +2199,6 @@ static int sctp_setsockopt_autoclose(str
 		return -EINVAL;
 	if (copy_from_user(&sp->autoclose, optval, optlen))
 		return -EFAULT;
-	/* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */
-	sp->autoclose = min_t(long, sp->autoclose, MAX_SCHEDULE_TIMEOUT / HZ);
 
 	return 0;
 }
--- 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];
@@ -258,6 +262,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 */ }
 };



  parent reply	other threads:[~2012-01-03 22:47 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-03 22:33 [00/75] 3.1.8-stable review Greg KH
2012-01-03 22:32 ` [01/75] ARM: OMAP: rx51: fix USB Greg KH
2012-01-03 22:32 ` [02/75] ipip, sit: copy parms.name after register_netdevice Greg KH
2012-01-03 22:32 ` [03/75] rtc: Expire alarms after the time is set Greg KH
2012-01-03 22:46   ` John Stultz
2012-01-03 22:53     ` Greg KH
2012-01-03 22:32 ` [04/75] rtc: m41t80: Workaround broken alarm functionality Greg KH
2012-01-03 22:32 ` [05/75] ALSA: HDA: Set position fix to LPIB for an Atom/Poulsbo based device Greg KH
2012-01-03 22:32 ` [06/75] drm/i915: set the right SDVO transcoder for CPT Greg KH
2012-01-03 22:32 ` [07/75] drm/i915: prevent division by zero when asking for chipset power Greg KH
2012-01-03 22:32 ` [08/75] cfq-iosched: free cic_index if blkio_alloc_blkg_stats fails Greg KH
2012-01-03 22:32 ` [09/75] cfq-iosched: fix cfq_cic_link() race confition Greg KH
2012-01-03 22:32 ` [10/75] SCSI: zfcp: return early from slave_destroy if slave_alloc returned early Greg KH
2012-01-03 22:32 ` [11/75] SCSI: mpt2sas: _scsih_smart_predicted_fault uses GFP_KERNEL in interrupt context Greg KH
2012-01-03 22:32 ` [12/75] SCSI: fcoe: Fix preempt count leak in fcoe_filter_frames() Greg KH
2012-01-03 22:32 ` [13/75] mac80211: fix another race in aggregation start Greg KH
2012-01-03 22:32 ` [14/75] ASoC: Fix WM8996 24.576MHz clock operation Greg KH
2012-01-03 22:32 ` [15/75] block: initialize request_queues numa node during Greg KH
2012-01-03 22:32 ` [16/75] ssb: fix init regression with SoCs Greg KH
2012-01-03 22:32 ` [17/75] rtl8192{ce,cu,de,se}: avoid problems because of possible ERFOFF -> ERFSLEEP transition Greg KH
2012-01-03 22:32 ` [18/75] MXC PWM: should active during DOZE/WAIT/DBG mode Greg KH
2012-01-03 22:32 ` [19/75] Input: synaptics - fix touchpad not working after S2R on Vostro V13 Greg KH
2012-01-03 22:32 ` [20/75] percpu: fix per_cpu_ptr_to_phys() handling of non-page-aligned addresses Greg KH
2012-01-03 22:32 ` [21/75] IB/mlx4: Fix shutdown crash accessing a non-existent bitmap Greg KH
2012-01-03 22:32 ` [22/75] binary_sysctl(): fix memory leak Greg KH
2012-01-03 22:32 ` [23/75] oom: fix integer overflow of points in oom_badness Greg KH
2012-01-03 22:32 ` [24/75] oprofile: Fix uninitialized memory access when writing to writing to oprofilefs Greg KH
2012-01-03 22:32 ` [25/75] SUNRPC: Ensure we always bump the backlog queue in xprt_free_slot Greg KH
2012-01-03 22:32 ` [26/75] NFS: Fix a regression in nfs_file_llseek() Greg KH
2012-01-03 22:33 ` [27/75] NFSv4.1: Ensure that we handle _all_ SEQUENCE status bits Greg KH
2012-01-03 22:33 ` [28/75] SELinux: Fix RCU deref check warning in sel_netport_insert() Greg KH
2012-01-03 22:33 ` [29/75] media: omap_vout: Fix compile error in 3.1 Greg KH
2012-01-03 22:33 ` [30/75] nilfs2: unbreak compat ioctl Greg KH
2012-01-03 22:33 ` [31/75] mmc: vub300: fix type of firmware_rom_wait_states module parameter Greg KH
2012-01-03 22:33 ` [32/75] cgroups: fix a css_set not found bug in cgroup_attach_proc Greg KH
2012-01-03 22:33 ` [33/75] mfd: Fix twl-core oops while calling twl_i2c_* for unbound driver Greg KH
2012-01-03 22:33 ` [34/75] vfs: __read_cache_page should use gfp argument rather than GFP_KERNEL Greg KH
2012-01-03 22:33 ` [35/75] media: s5p-fimc: Use correct fourcc for RGB565 colour format Greg KH
2012-01-03 22:33 ` [36/75] ath9k: fix max phy rate at rate control init Greg KH
2012-01-03 22:33 ` [37/75] iwlwifi: do not set the sequence control bit is not needed Greg KH
2012-01-03 22:33 ` [38/75] iwlwifi: allow to switch to HT40 if not associated Greg KH
2012-01-03 22:33 ` [39/75] memcg: keep root group unchanged if creation fails Greg KH
2012-01-03 22:33 ` [40/75] VFS: Fix race between CPU hotplug and lglocks Greg KH
2012-01-03 22:33 ` [41/75] ARM:imx:fix pwm period value Greg KH
2012-01-03 22:33 ` [42/75] ARM: 7214/1: mmc: mmci: Fixup handling of MCI_STARTBITERR Greg KH
2012-01-03 22:33 ` [43/75] ARM: 7220/1: mmc: mmci: Fixup error handling for dma Greg KH
2012-01-03 22:33 ` [44/75] oprofile, arm/sh: Fix oprofile_arch_exit() linkage issue Greg KH
2012-01-03 22:33 ` [45/75] futex: Fix uninterruptible loop due to gate_area Greg KH
2012-01-03 22:33 ` [46/75] watchdog: hpwdt: Changes to handle NX secure bit in 32bit path Greg KH
2012-01-03 22:33 ` [47/75] drm/radeon/kms: bail on BTC parts if MC ucode is missing Greg KH
2012-01-03 22:33 ` [48/75] mm: hugetlb: fix non-atomic enqueue of huge page Greg KH
2012-01-03 22:33 ` [49/75] mm/mempolicy.c: refix mbind_range() vma issue Greg KH
2012-01-03 22:33 ` [50/75] mpt2sas crashes on shutdown Greg KH
2012-01-04  8:53   ` Nandigama, Nagalakshmi
2012-01-04 15:18     ` Greg KH
2012-01-04 15:19     ` James Bottomley
2012-01-04 15:25       ` [PATCH] mpt2sas: fix non-x86 crash " James Bottomley
2012-01-04 19:21         ` Greg KH
2012-01-04 19:39           ` David Miller
2012-01-05 19:10         ` Patch "mpt2sas: fix non-x86 crash on shutdown" has been added to the 3.0-stable tree gregkh
2012-01-05 19:25         ` Patch "mpt2sas: fix non-x86 crash on shutdown" has been added to the 3.1-stable tree gregkh
2012-01-03 22:33 ` [51/75] sparc64: Fix MSIQ HV call ordering in pci_sun4v_msiq_build_irq() Greg KH
2012-01-03 22:33 ` [52/75] sparc32: Be less strict in matching %lo part of relocation Greg KH
2012-01-03 22:33 ` [53/75] sparc64: Patch sun4v code sequences properly on module load Greg KH
2012-01-03 22:33 ` [54/75] sparc: Kill custom io_remap_pfn_range() Greg KH
2012-01-03 22:33 ` [55/75] sparc32: Remove non-kernel code from memcpy implementation Greg KH
2012-01-03 22:33 ` [56/75] sparc32: Remove uses of %g7 in " Greg KH
2012-01-03 22:33 ` [57/75] sparc32: Correct the return value of memcpy Greg KH
2012-01-03 22:33 ` [58/75] sparc64: Fix masking and shifting in VIS fpcmp emulation Greg KH
2012-01-03 22:33 ` [59/75] sparc: Fix handling of orig_i0 wrt. debugging when restarting syscalls Greg KH
2012-01-03 22:33 ` [60/75] net: bpf_jit: fix an off-one bug in x86_64 cond jump target Greg KH
2012-01-03 22:33 ` [61/75] ppp: fix pptp double release_sock in pptp_bind() Greg KH
2012-01-03 22:33 ` [62/75] llc: llc_cmsg_rcv was getting called after sk_eat_skb Greg KH
2012-01-03 22:33 ` [63/75] mqprio: Avoid panic if no options are provided Greg KH
2012-01-03 22:33 ` [64/75] net: have ipconfig not wait if no dev is available Greg KH
2012-01-03 22:33 ` [65/75] sch_gred: should not use GFP_KERNEL while holding a spinlock Greg KH
2012-01-03 22:33 ` Greg KH [this message]
2012-01-03 22:33 ` [67/75] sctp: Do not account for sizeof(struct sk_buff) in estimated rwnd Greg KH
2012-01-03 22:33 ` [68/75] net: Add a flow_cache_flush_deferred function Greg KH
2012-01-03 22:33 ` [69/75] ipv4: flush route cache after change accept_local Greg KH
2012-01-03 22:33 ` [70/75] ipv6: Check dest prefix length on original route not copied one in rt6_alloc_cow() Greg KH
2012-01-03 22:33 ` [71/75] net: introduce DST_NOPEER dst flag Greg KH
2012-01-03 22:33 ` [72/75] ipv4: reintroduce route cache garbage collector Greg KH
2012-01-03 22:33 ` [73/75] ipv4: using prefetch requires including prefetch.h Greg KH
2012-01-03 22:33 ` [74/75] iwlwifi: update SCD BC table for all SCD queues Greg KH
2012-01-03 22:33 ` [75/75] mfd: Turn on the twl4030-madc MADC clock Greg KH
2012-01-05 19:26 ` [00/75] 3.1.8-stable review Greg KH
2012-01-05 22:36   ` Greg KH
2012-01-05 22:30     ` [49/80] mpt2sas: fix non-x86 crash on shutdown Greg KH
2012-01-05 22:30     ` [75/80] drm/radeon/kms/atom: fix possible segfault in pm setup Greg KH
2012-01-05 22:30     ` [76/80] hung_task: fix false positive during vfork Greg KH
2012-01-05 22:30     ` [77/80] Revert "rtc: Disable the alarm in the hardware" Greg KH
2012-01-05 22:30     ` [78/80] ptrace: partially fix the do_wait(WEXITED) vs EXIT_DEAD->EXIT_ZOMBIE race Greg KH
2012-01-05 22:30     ` [79/80] ptrace: ensure JOBCTL_STOP_SIGMASK is not zero after detach Greg KH
2012-01-05 22:30     ` [80/80] ath9k: Fix kernel panic in AR2427 in AP mode Greg KH
2012-01-05 19:29 ` [00/75] 3.1.8-stable review Linus Torvalds
2012-01-05 19:36   ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120103223326.624073171@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=xi.wang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome