Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3007072ybt; Mon, 29 Jun 2020 12:44:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+5G1MStz+xWrmm20OqAs4MxfqabJ9GtG4oappnCnczkR4IkWl8iLhgqw3ayIA5Brgq/i6 X-Received: by 2002:aa7:c314:: with SMTP id l20mr20057327edq.150.1593459874159; Mon, 29 Jun 2020 12:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593459874; cv=none; d=google.com; s=arc-20160816; b=MRtS0eAh93HoXnBorvGmqrNPrMZ3wyr4AZMLG2PXXCTUpqYCo43RggVxwfVzMMnFH5 IRgbqs1ZpJasB41ycT9Wkh+ZLAzNF8WmbyEt9AdZK90kSRDV8UeQPOMXKdMHE4TNd9hv nShEHhFfVpRg09krptih4jf6xzFHIpaYaklKOIP2NEO/q1cQJylU8h69AUzVbs6DtZnV TbQz0QpF1kedisvhsUJqgfH7syvHZKc68eJVsQmk6YKOYkuDSck/f/VQyqPWYz+EcKwt kzuw8yfIfEQUoBZYm+IRmgrDHn2FUAxEHU8AFw7RReNXWCtCFGIQmEyTZPsIl6i27kj1 jDSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=iP3PjzJ6XSqU6iD5jcFMqznuwbwfOTCeMrtF+SzoIxA=; b=dCKkCRKP2HaY14UxP0r4F4LT9e5nqhFSQ7PBhqM552nBZBAh6V4PmlAq52O5EYwYz4 TnVNWI66XZ+bd6CGSXMXFDOWfmqmkMTrdJbhGUEaezCrKIOGJnq/wea2KgCgpdiC/lPX yQMwHEX0MSJaKmyPL4ApQsPCZRssH1WOfhr2q30pcEM2ldanTDuVhCfaRstteXoAra8I X/RprlINgC8M3pQXXjZqUxLChzRm7QervzPoLV9gmpF5gj8M5Urusb2+NC1M16cI0gUh 7XTTyk/I/jdr3Apol2hTpoZ3q0loNr9PpCuRHZgNXa/1vfAnw5gir5cUGTl9zZsKzqcK koxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=Zb+p9V5X; 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=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h27si411552ejd.190.2020.06.29.12.44.11; Mon, 29 Jun 2020 12:44:34 -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=@efficios.com header.s=default header.b=Zb+p9V5X; 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=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387966AbgF2ToE (ORCPT + 99 others); Mon, 29 Jun 2020 15:44:04 -0400 Received: from mail.efficios.com ([167.114.26.124]:33194 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732797AbgF2Tn6 (ORCPT ); Mon, 29 Jun 2020 15:43:58 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 57E8026BE90; Mon, 29 Jun 2020 15:43:57 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jKS2OsRBiPF4; Mon, 29 Jun 2020 15:43:56 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id E456326BE04; Mon, 29 Jun 2020 15:43:56 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com E456326BE04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1593459836; bh=iP3PjzJ6XSqU6iD5jcFMqznuwbwfOTCeMrtF+SzoIxA=; h=Date:From:To:Message-ID:MIME-Version; b=Zb+p9V5XcwPNNTTPWdcilNsn2aGU2lz7a7/PgtBKt1e2OjYnYtasalPhFQHv4ygdd RkRpqOQNC5cXdmRmS+PZ+1R70E4ZmDs7Kr6tVw3oCykO7aRMtPklSP9nCYfccmzCjG F2OOszRVIlpNIL5uFP2fU24d5we1PKVV4hiBKQULZhBQqUY9y7EnArJF+Blx+eNaVf ooV5Bm2ZGojLC+Ntbfp1RjN3+t6syLAin22SMllmW5brKuATpfFUqnwjhk2EWNmQGm l5o5b5rOJXwzFqhFaW60/Vp7e4OvpH0Iw4TnlBzKuxIKzi+iibJankV9mFCenWMIwS tekm46Nbemxyg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QlU3a6Iszu31; Mon, 29 Jun 2020 15:43:56 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id D147626B9F3; Mon, 29 Jun 2020 15:43:56 -0400 (EDT) Date: Mon, 29 Jun 2020 15:43:56 -0400 (EDT) From: Mathieu Desnoyers To: Eric Dumazet , Linus Torvalds Cc: "David S. Miller" , linux-kernel , netdev , Yuchung Cheng , Jonathan Rajotte-Julien Message-ID: <1132973300.15954.1593459836756.JavaMail.zimbra@efficios.com> In-Reply-To: References: <341326348.19635.1589398715534.JavaMail.zimbra@efficios.com> Subject: Re: [regression] TCP_MD5SIG on established sockets MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3945 (ZimbraWebClient - FF77 (Linux)/8.8.15_GA_3928) Thread-Topic: TCP_MD5SIG on established sockets Thread-Index: 0Jvbhp6DCumjwNDk8z7Y2feQgYejnA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- 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. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com