From patchwork Mon Nov 22 22:54:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 72608 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 511E2B70FB for ; Tue, 23 Nov 2010 09:54:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932305Ab0KVWye (ORCPT ); Mon, 22 Nov 2010 17:54:34 -0500 Received: from mail-ew0-f46.google.com ([209.85.215.46]:56791 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932166Ab0KVWyd (ORCPT ); Mon, 22 Nov 2010 17:54:33 -0500 Received: by ewy5 with SMTP id 5so2104358ewy.19 for ; Mon, 22 Nov 2010 14:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=mOsh7btIaosgCgzbUhUZqcXDPzAtC2OAhwBjZxS0PrI=; b=CWxFJ+9nqxiHnslqEaIsHcJE3frkHjX9HQ0eLrUsdHeEL4RjCRs205DYoy29mHV8QP Ap88yDXg3VFuLkAos5Gis4DYVE9yroaF2M6Ru2UDhjUm4lixyA0UalAE+0ESUObRNtl1 J5Kkx+VFXVqQ67PJjsGJB+m/E3zV3OAIVROUI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=uXPZU0ZzkVwYd+6P0bpXDQMVl1LJ5WTRUSlog9HIQSYNImFMpg7iKnI2J1yPHVSupz mpgDm5ZrxruUyjCVGfDLXyxDq47h4ku1XbFn4mcb2c3zYwwZSDmS2jbNz5sUSgjooZF7 5EVbZlhjI04KSpXXHrFb5iuCMIHj/eeQUI33c= Received: by 10.213.8.140 with SMTP id h12mr1051605ebh.50.1290466466382; Mon, 22 Nov 2010 14:54:26 -0800 (PST) Received: from core2.telecom.by (vulture2-nat-44.telecom.by [213.184.224.44]) by mx.google.com with ESMTPS id v56sm5114552eeh.2.2010.11.22.14.54.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 22 Nov 2010 14:54:25 -0800 (PST) Date: Tue, 23 Nov 2010 00:54:21 +0200 From: Alexey Dobriyan To: davem@davemloft.net Cc: Eric Dumazet , shemminger@linux-foundation.org, netdev@vger.kernel.org, Ben Hutchings Subject: [PATCH v2] tcp: restrict net.ipv4.tcp_adv_win_scale (#20312) Message-ID: <20101122225421.GA7372@core2.telecom.by> References: <20101114151825.GA25137@core2.telecom.by> <1289764183.2743.94.camel@edumazet-laptop> <20101114201458.GA28181@core2.telecom.by> <1289830722.2586.5.camel@bwh-desktop> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1289830722.2586.5.camel@bwh-desktop> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org tcp_win_from_space() does the following: if (sysctl_tcp_adv_win_scale <= 0) return space >> (-sysctl_tcp_adv_win_scale); else return space - (space >> sysctl_tcp_adv_win_scale); "space" is int. As per C99 6.5.7 (3) shifting int for 32 or more bits is undefined behaviour. Indeed, if sysctl_tcp_adv_win_scale is exactly 32, space >> 32 equals space and function returns 0. Which means we busyloop in tcp_fixup_rcvbuf(). Restrict net.ipv4.tcp_adv_win_scale to [-31, 31]. Fix https://bugzilla.kernel.org/show_bug.cgi?id=20312 Steps to reproduce: echo 32 >/proc/sys/net/ipv4/tcp_adv_win_scale wget www.kernel.org [softlockup] Signed-off-by: Alexey Dobriyan --- Documentation/networking/ip-sysctl.txt | 1 + net/ipv4/sysctl_net_ipv4.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -144,6 +144,7 @@ tcp_adv_win_scale - INTEGER Count buffering overhead as bytes/2^tcp_adv_win_scale (if tcp_adv_win_scale > 0) or bytes-bytes/2^(-tcp_adv_win_scale), if it is <= 0. + Possible values are [-31, 31], inclusive. Default: 2 tcp_allowed_congestion_control - STRING --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -26,6 +26,8 @@ static int zero; static int tcp_retr1_max = 255; static int ip_local_port_range_min[] = { 1, 1 }; static int ip_local_port_range_max[] = { 65535, 65535 }; +static int tcp_adv_win_scale_min = -31; +static int tcp_adv_win_scale_max = 31; /* Update system visible IP port range */ static void set_local_port_range(int range[2]) @@ -426,7 +428,9 @@ static struct ctl_table ipv4_table[] = { .data = &sysctl_tcp_adv_win_scale, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = proc_dointvec_minmax, + .extra1 = &tcp_adv_win_scale_min, + .extra2 = &tcp_adv_win_scale_max, }, { .procname = "tcp_tw_reuse",