From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E770C43603 for ; Tue, 17 Dec 2019 20:16:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E15882465E for ; Tue, 17 Dec 2019 20:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576613802; bh=IHzMM2maoLgK/NDRYcIVKcvpPDeFmrfH5TzgT+2Ohak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YRNgkbEjSUcEjDrnvSYxtC28zCIwOR4FuyaN+79bY5uOuDTSy2MWX/Fx+YDvXfxg6 9lhDlVE9TD6yKHxEGSIqRO2XOhqetQ/KdL4VTOHsOjtE5mSQGXQbb7BUdSIF/be/AM 7OoM15J+ol+ZAgRAxgxFUOsUWnQjp9GCkXFvqmsk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728325AbfLQUQl (ORCPT ); Tue, 17 Dec 2019 15:16:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:40832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727594AbfLQUQi (ORCPT ); Tue, 17 Dec 2019 15:16:38 -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 6B7D221775; Tue, 17 Dec 2019 20:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576613797; bh=IHzMM2maoLgK/NDRYcIVKcvpPDeFmrfH5TzgT+2Ohak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3UiRzINpsCbt/Xo8I8g0Is4kfPkexJoTrWom6bCd4ZxK0FJf+zfbWe+YjxEhKWPK skUDjb+hyu9mClkFt3kvyRm1iMapmgNcSSg4jjL6HHR34r60PP2VGT9qIg1MxH4fO4 ocASpCtzpaU5DJo2aQxqcDeC066aLIK7FUQejeYE= 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 5.3 11/25] tcp: md5: fix potential overestimation of TCP option space Date: Tue, 17 Dec 2019 21:16:10 +0100 Message-Id: <20191217200908.055769377@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191217200903.179327435@linuxfoundation.org> References: <20191217200903.179327435@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 @@ -755,8 +755,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;