Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2277696ybl; Thu, 19 Dec 2019 10:54:02 -0800 (PST) X-Google-Smtp-Source: APXvYqxKS+NuipL/7+rkPyuS1jCJRR6qe8Z03ciomevIl3nyffkEZNbcRKSCdUzBRup9687NzFZq X-Received: by 2002:a05:6830:1248:: with SMTP id s8mr10327513otp.202.1576781642390; Thu, 19 Dec 2019 10:54:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781642; cv=none; d=google.com; s=arc-20160816; b=eoU0A+eA/hR0HmC29TT+L2rfQpj7LnyxmR+SesmWAvzXBfYkwpQOmeqsjW90W/ygQb TAU1xqetn14TilgsudJinjY2jOWxk6aVxwSvQX+dQxxkcgLJIdQng+U70ddLo7uFcm7j 0x9aP8vp8HbHtIOBoOjSD+qqjr4mpoje+AQzwzhxBTCuCOG9Z+VC+ROtfjRiHoxKnZ5K D7Qb0oph3qSV6t6go3Ck/gMksoQAjC6fHlIKeFNuiiZjzUrzRztGvpG9bsu9b58JV0mo 8UXXfyMP19XqLfkjoInKUVKWxqSxFU/f1fG9qgPJ5FTCgQ8Pd5xBx79H03I1SAXFvvT5 DqtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4GyJdOsr9E2l7rVPPgEX6CmfZHOirVXIEPZ97ZU2T7s=; b=IhiZkGfcWdNi17oKQQQZjivJj0qvkFFcVJqLBKG3oc4qd3nD4R4X942hmm2F2azEOw h2BLYasBlk9aiHzZR2D13lTZQWOQdkdGJ4zAiie06zugUoWXDrJFx5OUfT9UwNP6TRUO QDU5ZJrzYcJCK3hJxhqvBjhV4POhd8VSdiddMcZIlabQhr9Ww4bpAhBBwDLJoMWY9Xic pPrKbI5HNEKSpsN+GbyHWPuZQr9Ckvm9lYxTh6Mzk+6ZOSzSsGsEjg+gv+e3WSraNkoi DGK30YzyULGnb+DzNUALRzx9uYmbH7D8eBuIe4/sxnr5Iv62CHs6tAFVEvfq4OVXvuTO pm5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z1sChXQm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t185si3538206oib.39.2019.12.19.10.53.50; Thu, 19 Dec 2019 10:54:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z1sChXQm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730124AbfLSSwt (ORCPT + 99 others); Thu, 19 Dec 2019 13:52:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:47508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730289AbfLSSwr (ORCPT ); Thu, 19 Dec 2019 13:52:47 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F00C6222C2; Thu, 19 Dec 2019 18:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781566; bh=MSTmn19y5LfHBUQ5A/ONZHHDbesMDuEavtreafrtXao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z1sChXQmsQOCN+F1sF4XPcJUqEo87zUxBpngRwCRy16mTr0J3ApR6LE8EWjMLHmyX u7yjtJgvaRefJNpZ0+7UEe4kAt3VtEKi7AXzjdWhR8UB/PI1ZnlUUmNqrXUhNrhepG gDAX+RuUvR/wJl2It06Qtr/sxxmWpzvCmlsPhFxA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , syzbot , Neal Cardwell , Soheil Hassas Yeganeh , "David S. Miller" Subject: [PATCH 4.19 09/47] tcp: md5: fix potential overestimation of TCP option space Date: Thu, 19 Dec 2019 19:34:23 +0100 Message-Id: <20191219182906.185214546@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219182857.659088743@linuxfoundation.org> References: <20191219182857.659088743@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 9424e2e7ad93ffffa88f882c9bc5023570904b55 ] Back in 2008, Adam Langley fixed the corner case of packets for flows having all of the following options : MD5 TS SACK Since MD5 needs 20 bytes, and TS needs 12 bytes, no sack block can be cooked from the remaining 8 bytes. tcp_established_options() correctly sets opts->num_sack_blocks to zero, but returns 36 instead of 32. This means TCP cooks packets with 4 extra bytes at the end of options, containing unitialized bytes. Fixes: 33ad798c924b ("tcp: options clean up") Signed-off-by: Eric Dumazet Reported-by: syzbot Acked-by: Neal Cardwell Acked-by: Soheil Hassas Yeganeh Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_output.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -740,8 +740,9 @@ static unsigned int tcp_established_opti min_t(unsigned int, eff_sacks, (remaining - TCPOLEN_SACK_BASE_ALIGNED) / TCPOLEN_SACK_PERBLOCK); - size += TCPOLEN_SACK_BASE_ALIGNED + - opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK; + if (likely(opts->num_sack_blocks)) + size += TCPOLEN_SACK_BASE_ALIGNED + + opts->num_sack_blocks * TCPOLEN_SACK_PERBLOCK; } return size;