Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3046366ybt; Mon, 29 Jun 2020 13:50:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp2OO9Ux/4xRCUChk+Dmgqf3DQOunTAHwzxAFzrS2owXdZ6vQrwpGsEwDulAe/u6ddlMg2 X-Received: by 2002:aa7:d2d2:: with SMTP id k18mr19034055edr.16.1593463855413; Mon, 29 Jun 2020 13:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593463855; cv=none; d=google.com; s=arc-20160816; b=ofRUU3YnSpu4qdtkY0AfZ7MqYjO/Q4WcuIhZJFZsjcwz7dThAjV8z3QAwQSNwQxr3L Owr0bykPdU65MCnv48iBHCxi/DgrYXqW9XEmhLU7U1aJXnhlqH5bA9yukbL7hnLBjNm1 jMi6lMiLvSN5vQGu6sq42F69N0yIML0zJWEA6Dzf8QaM/1EHwTOdQXPne6OU7xPeta+M XQuG139AlqvKUn20M+s1CfyAEyxJSv+oSKcsLpGc/0yN5reiX/h/FcsBlafdNuaEalgN eUGgrmrYlUQaBltfrXNLS3s3z3uKQQsQG2mZq3HUcOeosOTfAgg3bYvg6weZd8/QTZN+ JY3Q== 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=UYdsVW3BBX8OC9WrPhf4Ap0SclutgAMBOwsFuhmAiUc=; b=GjwarRfcloqZT2Om/BGYu2l/XGkKisInMEJXXcZw0v5DMWK97+Va3OQXo0gXV3ZTyZ lKYOvUyp8ZOkfS3RVEPf1cC7zzi18TxsANSxPR4IF/Yzpr0YVB4pZSZ3Cu9QEvOThzCf mELNm1RBW0/sBGg/jFWG28hrsFhuv9FhrdZnxyWymwhyF4iw6H0UW2sTFGGPfXztkL0V ba5rPmHWBCWIjl+7L+6+IxsK3aV0zWcHrDcFN4nqB9+/0zGHFlNkhXthS00XpnT2c0I3 HQMRut7abyMSfFypr1on/REgayXxPYGK+IEmkjuaNqrbuXFmpMsAqznv4V2QLorfJ4mv V6Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sj3Z3WaQ; 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 y24si309158edv.573.2020.06.29.13.50.32; Mon, 29 Jun 2020 13:50:55 -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=sj3Z3WaQ; 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 S2389801AbgF2Urc (ORCPT + 99 others); Mon, 29 Jun 2020 16:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389787AbgF2UrY (ORCPT ); Mon, 29 Jun 2020 16:47:24 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FF3AC03E979 for ; Mon, 29 Jun 2020 13:47:24 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id j19so5999850ybj.1 for ; Mon, 29 Jun 2020 13:47:24 -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=UYdsVW3BBX8OC9WrPhf4Ap0SclutgAMBOwsFuhmAiUc=; b=sj3Z3WaQ1XCj7qzBWUHl68lvUTLwnu6zeQufplCvQ7tx0Qlt+QJveoGV1nfGTLWyLv M9vMyUf7RdkMji4al4luUrBJcN0XeDmkmrOP/FKVt6KzO3zJABVlVDOmki4v00ZinZsG W3QatwpjQU/iv2XPFNkb3pk0fgKTqufJuLYy7G9ouIXrZNHI0mXMv8bpiQaKt1wr0Hey zXQiFGGxuXjY2dwQ4qTyezFna1+McjHL8mJYxtwlnFmhj8/4Na+fIdw6DCLrOsEZz6vp nrfN7LVua3jDjmxgQfa07/uAThOHhECLgI6qrP4c4P5428H7aUw8G6BVfA7qjCy+fXsF LhdQ== 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=UYdsVW3BBX8OC9WrPhf4Ap0SclutgAMBOwsFuhmAiUc=; b=DszULbdszLBJsLGMGbEZueKHbI6Jb3mMqKFjmsAJ5qP/nfrRmMum9Zo893jz7wdwJy Z9OZY5W/XGUIByKbpCx7zBc2k5CTBgrHyFM13DxKFmKWPgdnG7hrV3j37OKzitwwBeuj lH5Rmb1HIA/P2kE5QK7X8eeIYcnoPpn662JEju3pG6MLoXbv1TgsMsMdY+HZUnaxkski 3mYe4T2CSxeutiaYgtVep2dN/sKVJt7zHMJ3mWoIAuSU7zSvTZKXK+B8U++nWylGAncC m2LbS/FpYl3r3nan6UVfL0rDWALPmYSIbwfSnxXwgHzYO7TUa/m8s/wM/luNOyo+d2o7 FesA== X-Gm-Message-State: AOAM533VFIdD9Cswk2HhgufPfEtTTtIROW5R/Xm6bHCjM8nRaUmf8xkX 6alBQZ9AEKQ4arUJ6JhX0DMecqLpmiXUnHkZW7XIkw== X-Received: by 2002:a25:cd87:: with SMTP id d129mr27206628ybf.395.1593463642859; Mon, 29 Jun 2020 13:47:22 -0700 (PDT) MIME-Version: 1.0 References: <341326348.19635.1589398715534.JavaMail.zimbra@efficios.com> <1132973300.15954.1593459836756.JavaMail.zimbra@efficios.com> In-Reply-To: <1132973300.15954.1593459836756.JavaMail.zimbra@efficios.com> From: Eric Dumazet Date: Mon, 29 Jun 2020 13:47:11 -0700 Message-ID: Subject: Re: [regression] TCP_MD5SIG on established sockets To: Mathieu Desnoyers Cc: Linus Torvalds , "David S. Miller" , 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 Mon, Jun 29, 2020 at 12:43 PM Mathieu Desnoyers wrote: > > ----- On May 13, 2020, at 3:56 PM, Eric Dumazet edumazet@google.com wrote: > > > On Wed, May 13, 2020 at 12:49 PM Eric Dumazet wrote: > >> > >> > >> On Wed, May 13, 2020 at 12:38 PM Mathieu Desnoyers > >> wrote: > >> > > >> > Hi, > >> > > >> > I am reporting a regression with respect to use of TCP_MD5SIG/TCP_MD5SIG_EXT > >> > on established sockets. It is observed by a customer. > >> > > >> > This issue is introduced by this commit: > >> > > >> > commit 721230326891 "tcp: md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT on > >> > established sockets" > >> > > >> > The intent of this commit appears to be to fix a use of uninitialized value in > >> > tcp_parse_options(). The change introduced by this commit is to disallow setting > >> > the TCP_MD5SIG{,_EXT} socket options on an established socket. > >> > > >> > The justification for this change appears in the commit message: > >> > > >> > "I believe this was caused by a TCP_MD5SIG being set on live > >> > flow. > >> > > >> > This is highly unexpected, since TCP option space is limited. > >> > > >> > For instance, presence of TCP MD5 option automatically disables > >> > TCP TimeStamp option at SYN/SYNACK time, which we can not do > >> > once flow has been established. > >> > > >> > Really, adding/deleting an MD5 key only makes sense on sockets > >> > in CLOSE or LISTEN state." > >> > > >> > However, reading through RFC2385 [1], this justification does not appear > >> > correct. Quoting to the RFC: > >> > > >> > "This password never appears in the connection stream, and the actual > >> > form of the password is up to the application. It could even change > >> > during the lifetime of a particular connection so long as this change > >> > was synchronized on both ends" > >> > > >> > The paragraph above clearly underlines that changing the MD5 signature of > >> > a live TCP socket is allowed. > >> > > >> > I also do not understand why it would be invalid to transition an established > >> > TCP socket from no-MD5 to MD5, or transition from MD5 to no-MD5. Quoting the > >> > RFC: > >> > > >> > "The total header size is also an issue. The TCP header specifies > >> > where segment data starts with a 4-bit field which gives the total > >> > size of the header (including options) in 32-byte words. This means > >> > that the total size of the header plus option must be less than or > >> > equal to 60 bytes -- this leaves 40 bytes for options." > >> > > >> > The paragraph above seems to be the only indication that some TCP options > >> > cannot be combined on a given TCP socket: if the resulting header size does > >> > not fit. However, I do not see anything in the specification preventing any > >> > of the following use-cases on an established TCP socket: > >> > > >> > - Transition from no-MD5 to MD5, > >> > - Transition from MD5 to no-MD5, > >> > - Changing the MD5 key associated with a socket. > >> > > >> > As long as the resulting combination of options does not exceed the available > >> > header space. > >> > > >> > Can we please fix this KASAN report in a way that does not break user-space > >> > applications expectations about Linux' implementation of RFC2385 ? > [...] > >> > [1] RFC2385: https://tools.ietf.org/html/rfc2385 > >> > >> > >> I do not think we want to transition sockets in the middle. since > >> packets can be re-ordered in the network. > >> > >> MD5 is about security (and a loose form of it), so better make sure > >> all packets have it from the beginning of the flow. > >> > >> A flow with TCP TS on can not suddenly be sending packets without TCP TS. > >> > >> Clearly, trying to support this operation is a can of worms, I do not > >> want to maintain such atrocity. > >> > >> RFC can state whatever it wants, sometimes reality forces us to have > >> sane operations. > >> > >> Thanks. > >> > > Also the RFC states : > > > > "This password never appears in the connection stream, and the actual > > form of the password is up to the application. It could even change > > during the lifetime of a particular connection so long as this change > > was synchronized on both ends" > > > > It means the key can be changed, but this does not imply the option > > can be turned on/off dynamically. > > > > The change discussed previously (introduced by commit 721230326891 "tcp: > md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT on established sockets") breaks > user-space ABI. As an example, the following BGP application uses > setsockopt TCP_MD5SIG on a live TCP socket: > > https://github.com/IPInfusion/SDN-IP > > In addition to break user-space, it also breaks network protocol > expectations for network equipment vendors implementing RFC2385. > Considering that the goal of these protocols is interaction between > different network equipment, breaking compatibility on that side > is unexpected as well. Requiring to bring down/up the connection > just to change the TCP MD5 password is a no-go in networks with > high availability requirements. Changing the BGP authentication > password must be allowed without tearing down and re-establishing > the TCP sockets. Otherwise it doesn't scale for large network > operators to have to individually manage each individual TCP socket > in their network. However, based on the feedback I received, it > would be acceptable to tear-down the TCP connections and re-establish > them when enabling or disabling the MD5 option. > > Here is a list of a few network vendors along with their behavior > with respect to TCP MD5: > > - Cisco: Allows for password to be changed, but within the hold-down > timer (~180 seconds). > - Juniper: When password is initially set on active connection it will > reset, but after that any subsequent password changes no network > resets. > - Nokia: No notes on if they flap the tcp connection or not. > - Ericsson/RedBack: Allows for 2 password (old/new) to co-exist until > both sides are ok with new passwords. > - Meta-Switch: Expects the password to be set before a connection is > attempted, but no further info on whether they reset the TCP > connection on a change. > - Avaya: Disable the neighbor, then set password, then re-enable. > - Zebos: Would normally allow the change when socket connected. > > If you want to be able to _change_ md5 key, this is fine by me, please send a patch. We can not dynamically turn on MD5, this is mentioned briefly in tcp_synack_options(). If you want to turn on MD5 on an established flow, then you must ensure that both SACK and TS were not enabled in the 3WHS, and then make sure nothing blows up in the stack.