Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp715205imm; Thu, 13 Sep 2018 06:43:56 -0700 (PDT) X-Google-Smtp-Source: ANB0VdacL8YktMZcCllhY1188gDbFy2JcVXuCW/ZQMpmGQs12T8Y4rk9b5BIwRWHl+BQISvausp9 X-Received: by 2002:a62:1e81:: with SMTP id e123-v6mr7584931pfe.24.1536846236734; Thu, 13 Sep 2018 06:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846236; cv=none; d=google.com; s=arc-20160816; b=QLKd0JQYGea7V0uNLmTzJUMurtf38Et9JSon9+x5wGE6IoFOVIKM82Se2xMFGfsu76 0F2ugxeXlcaANtTbAwtF2Bn3cJZ8Hq8WR1ytCmkuie0VMMsobDqUI6sUG2tYpYGHfT+W RB2AYDbV44QGKVoQqsyZeEaeSJggh0cRWy/Pf5q38PZ1LcA9hNjjm1NB0XMwhyGxOFDq 4dpFJjk76qlFrKivT4ntL8d8qJhL0pvuCTff+UqiqthvdF8woCZvcB4ZHVw7fZfXFw0z Wrl4FV7ol7az+hEoQwuqf9mLYshahcUqgQ5X/ckel//MtGBYQsyAoy2+kXy8kZte3mxH ZE0w== 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; bh=ZcTnFhs2dO+nBUn0s5kD+Vh28mLvYHMgDjbQjlPAVDY=; b=Iq8GpEcwPuWGQ+7xCF6DyRHgeatSEbGcPwqOlOEQZzaH2tKy4hoLXuzUkORIkhI5WP CUfquJBRaQqbnoNMX1vwU2hGRsXyVSJZS0MQgnsJXLp65/dxZvSpauuQQ2UgOmkO1ne2 bzcnvClwnu8i+wBuYHHL1e01l9gCnoHngggSh5arZh4n9xod+6Nihd/nDENUUaMjeNHH q2moYe7McJ5jxQTgfrILW7PUQe9B86PZd0/4MhJEeJXYttHJ9CyJX/S/Cm5w6+TFE4VV AzhOAoWfAxg0SW2KtQoACZbwkh+yx0Pj+qPt1qt7b2Y3gMQ6cOA2L/BLF2TTdoOZcNHs rFAQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v132-v6si4236171pfc.193.2018.09.13.06.43.41; Thu, 13 Sep 2018 06:43:56 -0700 (PDT) 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; 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 S1729689AbeIMSvZ (ORCPT + 99 others); Thu, 13 Sep 2018 14:51:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60082 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727534AbeIMSvY (ORCPT ); Thu, 13 Sep 2018 14:51:24 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6B0EAD19; Thu, 13 Sep 2018 13:41:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Geoff Alexander , "David S. Miller" Subject: [PATCH 4.14 002/115] ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state Date: Thu, 13 Sep 2018 15:30:22 +0200 Message-Id: <20180913131823.486289563@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 431280eebed9f5079553daf003011097763e71fd ] tcp uses per-cpu (and per namespace) sockets (net->ipv4.tcp_sk) internally to send some control packets. 1) RST packets, through tcp_v4_send_reset() 2) ACK packets in SYN-RECV and TIME-WAIT state, through tcp_v4_send_ack() These packets assert IP_DF, and also use the hashed IP ident generator to provide an IPv4 ID number. Geoff Alexander reported this could be used to build off-path attacks. These packets should not be fragmented, since their size is smaller than IPV4_MIN_MTU. Only some tunneled paths could eventually have to fragment, regardless of inner IPID. We really can use zero IPID, to address the flaw, and as a bonus, avoid a couple of atomic operations in ip_idents_reserve() Signed-off-by: Eric Dumazet Reported-by: Geoff Alexander Tested-by: Geoff Alexander Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_ipv4.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2468,6 +2468,12 @@ static int __net_init tcp_sk_init(struct if (res) goto fail; sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); + + /* Please enforce IP_DF and IPID==0 for RST and + * ACK sent in SYN-RECV and TIME-WAIT state. + */ + inet_sk(sk)->pmtudisc = IP_PMTUDISC_DO; + *per_cpu_ptr(net->ipv4.tcp_sk, cpu) = sk; }