Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp723871imm; Thu, 13 Sep 2018 06:51:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaxTJanH7ZpOq56zsguRmXWrwWkWwHnYtNZyj4fEoxjmVPB4YJ+RvUBgn6jYWgCpabkrKJk X-Received: by 2002:a63:9551:: with SMTP id t17-v6mr7125845pgn.432.1536846709002; Thu, 13 Sep 2018 06:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846708; cv=none; d=google.com; s=arc-20160816; b=ksfKsIfvUzX9g2m8gGlDDtGUE/37BkHLuUp/PNJeS24rGQJmY1C0CTMM8+oLTmXKnS Y9uDgCzHOC4IvdgygyN9pRkny80GvjQPf40up7PGAJYUC5VfFt+PQTKQk6SPok7zprzS YaJqNjvE6ZkUH0qr5lTrNzCRpY9lLXJkaEAf/kX4HqIVosd4QeDjX3PJefqjg0rtNbjK ytqujOZ8sXJcYjiVZLKyhSm3HlL2LZFa/bWafs/xsmhw/FkpqyRXKRQB4ddG922d7ou0 qap4KMM5HEmA0cyYticaVP9ZCg5yWj8o6Q8cA1rc/uNApsm12SY5lmhLfb4UKKEOF1SV wZsw== 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=Q3WqrbpVEv42XT3hII+en26PbxLcD243O5gQq6XLG9o=; b=1FYFjV2LmUsCQrW0YX6x9wQOH3+F0wRu1GVRd02YttpTtioJFBcjf6UHyNNeQh/Yld 0YV7D9QU1C2TL/Td5ZiTy+daJVFZypgfgxRVfwvbBs3Q6+2WVvgxCr2rHkNQV90tqeDp b8taDKsfLK4iGXRMQUAcyVtM1EUjP4iQ8VlUT1eWt/+ctD0vKSjc9LN3to35iCYrmJVY d+gzfecpnqIyuOhdrbHgPbxFxD2LJjiE1GzjjiCRdubw1hcUCemzyDOfIYSAY8oyHBG9 4m2uBycbzAYCLbMU436nAqXcvWS2P3WvehF0EjYsZmTAJ6A9KIHyEjBzKEwl19qQzGwv suQA== 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 j9-v6si4281931pgm.428.2018.09.13.06.51.33; Thu, 13 Sep 2018 06:51:48 -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 S1730785AbeIMTAn (ORCPT + 99 others); Thu, 13 Sep 2018 15:00:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33252 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728484AbeIMTAn (ORCPT ); Thu, 13 Sep 2018 15:00:43 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 309D4CFE; Thu, 13 Sep 2018 13:51:08 +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.18 002/197] ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state Date: Thu, 13 Sep 2018 15:29:11 +0200 Message-Id: <20180913131841.663578061@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@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.18-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 @@ -2516,6 +2516,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; }