Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp77059ybt; Tue, 30 Jun 2020 15:11:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmNgdvatSFeEsHiCEfUiJ5csK5XnZBV7UPBWyVTwV1G2rJPeG8jBFrdWl8uzrZZDd666Ar X-Received: by 2002:a50:b065:: with SMTP id i92mr26972398edd.112.1593554620227; Tue, 30 Jun 2020 15:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593554620; cv=none; d=google.com; s=arc-20160816; b=Kv+7GyVZOtnm/4L1nspMQec4xgWXQXflN0Vb54mZ1x1M2hRp5H3cqSuUX1FZqCU0aM 0O70zpQV084A+iEaD5KsKbO3Z2RTgAcPLziEX/6uXvBf07de5E7KjbJUhBNqm57RIr0a uVeY36eU0IyN65RwlY9dIIilYiQLEvjBTYPllBnL/HKH7N9JeuBROoY2eZDP9EblrAko SvUcAOtOKroyHIvhMTqMud8WZK6rL293gIQ6IpRXgK9doewlRuZSfQ3VIWTfJaJUK4AN Gsk39JUQXbU/ESvqR13SmyFEt6CjlQcZU2EGF20NuO11pKG/4LplhUXoRKVWC+CYwcwT pxYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TH9ubu+kB9wsPTPtDqtZV/d7ZAkRM6RQc2M+/0BpphA=; b=C1/xEvBdPBzH5/qVACAuxYfbkbGZ43cEZD9AYRH8MYBtBhT4gjZJJeQJ2W9I0uh1LY X4uSvPFcuYrw5Snj+PTvcT/ih+vDgHR0ZiQmyGzQPShngMKaasG4yqHXDmhfL273Ye2P 9GnyPb16YTbLEjE6GYuV4/Wdu1Eg9Sorvo45dnwixa04rjh7jRpmQT9lf6gISZoywpXK zwxhrjOibIvPV8SYGBYlg+V814834imA3ZiaggXgSuc4YTY8nUOWazsWs4looMKSESc5 WhSbtBDbftGXvkPAwwIrSGnsNVg8FWRHARBEOfadiGh95Ge3BUTdxboff7JuonGaR3x4 RZ1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TVEfKY2G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du22si3300810ejc.330.2020.06.30.15.03.03; Tue, 30 Jun 2020 15:03:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TVEfKY2G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726187AbgF3Vyx (ORCPT + 99 others); Tue, 30 Jun 2020 17:54:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbgF3Vyw (ORCPT ); Tue, 30 Jun 2020 17:54:52 -0400 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5CEEC061755 for ; Tue, 30 Jun 2020 14:54:52 -0700 (PDT) Received: by mail-yb1-xb43.google.com with SMTP id m16so10864983ybf.4 for ; Tue, 30 Jun 2020 14:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TH9ubu+kB9wsPTPtDqtZV/d7ZAkRM6RQc2M+/0BpphA=; b=TVEfKY2GaQrYrQAhznDmdCfFbFwwH3JVS94HwR4ejRRgUn9JqaLe/78BCO/n2zarw1 +TIxvdlSHL9+n9XZPzN/g7WfHSH1aCx0txqYZGIFoRV2So10mEyFqosPHpfdk18dkiag rClNDqXs3xsBqx1yFcd6+QRT7gDWl6djfWuQrPNURGp8cbh49bXKMROozbrFI+zYTryo mx7sNVeeV+zXMCCWwDaG80VYj1AlZTw4MOWo8UIjSqmKEOr5E4D8h1bhapPV2Wgoq0c3 f/jnYtLTMCRxwscNgPxbfnPthBCHZOy5IW82bL8oQXxHGgLEGs02NqKhmw4mPlyx3nLm 2mxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TH9ubu+kB9wsPTPtDqtZV/d7ZAkRM6RQc2M+/0BpphA=; b=Kvz/0I8tCcspLEtpJaLoZCV1RIfA8xsUaVcjyW7M7nG9zzxHuqSD8OAe8kpsAIsefw ZfCHJDHenQh7WqP1KlLiZyY5uTm4yWGGN2t4a3PZSoo7khWYqAvmVnE2wgWrQT1RFWmp qQw52Od750FIvM2hanSGzBdZMuUdjRyX10r3FYQ5ZBhMgb8Wn1iuyEXH8Phlyjt+cLwT Nh/QrMdEILb82ukK9CwaDhN13CpRdnqmJHcv9S0tdSh66yBkZa+lUC3n9UzoHSFoXDmZ e6/P9v1v811s8AgMxO1rys0P9SCJzgv40ui+jQsGRd3AEN4VByFDH71y5sjGCKn1glol qKag== X-Gm-Message-State: AOAM531Qk80Gx8bgUOmxkR5CnQw0DqKWJXij+8I8T94qA9mq++avtifz j9H7T9U+B/IZ+sPJPV71w5OYvnOjTmtDujO1gDyBZQ== X-Received: by 2002:a25:81c2:: with SMTP id n2mr14682053ybm.520.1593554091451; Tue, 30 Jun 2020 14:54:51 -0700 (PDT) MIME-Version: 1.0 References: <312079189.17903.1593549293094.JavaMail.zimbra@efficios.com> <20200630.134429.1590957032456466647.davem@davemloft.net> <474095696.17969.1593551866537.JavaMail.zimbra@efficios.com> In-Reply-To: From: Eric Dumazet Date: Tue, 30 Jun 2020 14:54:39 -0700 Message-ID: Subject: Re: [regression] TCP_MD5SIG on established sockets To: Mathieu Desnoyers Cc: "David S. Miller" , Linus Torvalds , linux-kernel , netdev , Yuchung Cheng , Jonathan Rajotte-Julien Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 2:23 PM Eric Dumazet wrote: > > On Tue, Jun 30, 2020 at 2:17 PM Mathieu Desnoyers > wrote: > > > > ----- On Jun 30, 2020, at 4:56 PM, Eric Dumazet edumazet@google.com wrote: > > > > > On Tue, Jun 30, 2020 at 1:44 PM David Miller wrote: > > >> > > >> From: Eric Dumazet > > >> Date: Tue, 30 Jun 2020 13:39:27 -0700 > > >> > > >> > The (C) & (B) case are certainly doable. > > >> > > > >> > A) case is more complex, I have no idea of breakages of various TCP > > >> > stacks if a flow got SACK > > >> > at some point (in 3WHS) but suddenly becomes Reno. > > >> > > >> I agree that C and B are the easiest to implement without having to > > >> add complicated code to handle various negotiated TCP option > > >> scenerios. > > >> > > >> It does seem to be that some entities do A, or did I misread your > > >> behavioral analysis of various implementations Mathieu? > > >> > > >> Thanks. > > > > > > Yes, another question about Mathieu cases is do determine the behavior > > > of all these stacks vs : > > > SACK option > > > TCP TS option. > > > > I will ask my customer's networking team to investigate these behaviors, > > which will allow me to prepare a thorough reply to the questions raised > > by Eric and David. I expect to have an answer within 2-3 weeks at most. > > > > Thank you! > > > Great, I am working on adding back support for (B) & (C) by the end of > this week. Note that the security issue (of sending uninit bytes to the wire) has been independently fixed with [1] This means syzbot was able to have MD5+TS+SACK ~6 months ago. It seems we (linux) do not enable this combination for PASSIVE flows, (according to tcp_synack_options()), but for ACTIVE flows we do nothing special. So maybe code in tcp_synack_options() should be mirrored to tcp_syn_options() for consistency. (disabling TS if both MD5 and SACK are enabled) [1] commit 9424e2e7ad93ffffa88f882c9bc5023570904b55 Author: Eric Dumazet Date: Thu Dec 5 10:10:15 2019 -0800 tcp: md5: fix potential overestimation of TCP option space 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 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index be6d22b8190fa375074062032105879270af4be5..b184f03d743715ef4b2d166ceae651529be77953 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -755,8 +755,9 @@ static unsigned int tcp_established_options(struct sock *sk, struct sk_buff *skb 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;