From patchwork Tue May 9 22:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Safonov X-Patchwork-Id: 91777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3213808vqo; Tue, 9 May 2023 15:36:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6jD6RCSI/m3TWyb0nepMKf4S1bFvfeqo3byfk1DoWLtvxL/wf1QKWYwr23h/HsNe2ibVUf X-Received: by 2002:a05:6a20:7348:b0:f0:98ff:97e2 with SMTP id v8-20020a056a20734800b000f098ff97e2mr19893281pzc.24.1683671771806; Tue, 09 May 2023 15:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683671771; cv=none; d=google.com; s=arc-20160816; b=e+XHFsVfMXDqQEtu18eCQUlpDtqTI9RdiRUZ9Q36sHHHeFhOMn2GFOYyh1DQzwmJhz qp9syG0RocEyJRbaDzbg35ltCln//SFDI16xKnX2dC3xQyCXw1yStDbV6Nrho2zsFwF5 gWidkXVlmguVK+E/+rcehbcIDdhmQfqDxktqP1Jxdm9+RXzj8VCwb2v0sMIjE4k4Jopy 6hoMADRsO92of7UMdffNjp36pfhuLcoXTVS0ErR7DWvBlr673+wMTW/2lI4nJ/HU7kOj Lx5NGFs4DrxDohwuOPSTdherLPGPb/qdnWZUc96NAlE8b/C04gAIc4p5gFRO6X5WjZO3 6XMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Lc+xA7tlcC6A/HLIGYglx4S12hhfgqdXTKqlDOHD+8g=; b=rGk9UbtzprLNK/0rpSix6nvjWGvQvy+io66rrUMX79kgEwgAaMT6RkEpCKaoqRKPYb 7wQv91bMJNQFAcJnx9Zh3rUupkm8Q6kFrGbFu2h3R6XwPcCbdL7eUJDYASMaQmj+Xq6L zIZM/7/aTkqM1pvlUhozHUXFr0tmzsOjNtGyn2fodsXvz9fY7ldZ3nDMONGcksCJXqaM DDqs11cMOU4IMd497jDmWcCVl31P+F0COv0w5kWdqgtlvjMMSJAtntp2YPRt/1DPWo5g CCNcFs41V23w5s8renzSv3YTfzgHP4qXu6zXUo2zceJ7jgPRY6HoZ9gQVSOwGVK/s3MG WgjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=MzlgfUUA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h26-20020aa796da000000b0063b630df52asi3404033pfq.252.2023.05.09.15.35.54; Tue, 09 May 2023 15:36:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=MzlgfUUA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235637AbjEIWQh (ORCPT + 99 others); Tue, 9 May 2023 18:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235281AbjEIWQX (ORCPT ); Tue, 9 May 2023 18:16:23 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D3B046A2 for ; Tue, 9 May 2023 15:16:22 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f42b984405so9829655e9.3 for ; Tue, 09 May 2023 15:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; t=1683670581; x=1686262581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lc+xA7tlcC6A/HLIGYglx4S12hhfgqdXTKqlDOHD+8g=; b=MzlgfUUAYES98I8Blt0uDfqbqzdhCiYd3z2QxUhekOknoxQbNIgpLRyzMq1Xmch7h8 HItqYCSavUCqWy6kHsNZ0BcKI0OVSRDn6fwwYEQTXfplkFaQkswuICiX2I3//M9E6kAB P2nMX2EJLEkjUiRmfAAJoiyX555vwsTfgrWbc6FYyR/Pab9SfAR5yRxBmcBmTuaTDhmf jz/2BVV0PIEB5rr4S6tBalg4PrONuoUJJVDKZoAR+ajpq3NwV9XoZ8Lq2Nc2Avbp4q9O tXCn4Yl6HwngLAP+Lu+i6S3wv4Uhh/lPDtEwx1EtJpazHkWWT3scsIQqIIemzg+mHVwv Jrdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683670581; x=1686262581; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lc+xA7tlcC6A/HLIGYglx4S12hhfgqdXTKqlDOHD+8g=; b=e7nboUehhW3eh8B3RnjK1JuJ852PomWzmK3d/M29BQKxUQ/jaRqDneduDL4kLZynnY 1ZOzv3uoWhEkb1A9/3x0EW2cTCrg/bgtn+M0jFiuHIxFL3TyDN4H0tFYan8iVpex02O8 9uAE3pUo0PTaylvuwU/+xWUhbjt0TpYwb+v9rq0Z22s6BuJia7IRRxEFI8S33wb/H2lI MdZ9aoK36Xt/ot1iRdtZz77LQak0xXouxIH3yg5u/NBlXQjlg5OQI4ny1ptBNPTgh8D6 cs3mGHICS0gHc9TOjb9Cm0syXxI1vauqcFfXdVW64gsLcC6VOLsLVGKHxphTzEfHNlB/ Utqg== X-Gm-Message-State: AC+VfDzckS2F/HYHEUlTIbP97WYaHiOE5C6/uTzPrKCvo/rPJeiBLJQ7 w1Sk0RlPpWcofQQBry9D5KKRS561cf5xecwAW7c= X-Received: by 2002:a1c:f20a:0:b0:3f1:819d:d050 with SMTP id s10-20020a1cf20a000000b003f1819dd050mr10537973wmc.37.1683670580862; Tue, 09 May 2023 15:16:20 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id t25-20020a7bc3d9000000b003f42d3111b8sm2052888wmj.30.2023.05.09.15.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 15:16:20 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org, David Ahern , Eric Dumazet , Paolo Abeni , Jakub Kicinski , "David S. Miller" Cc: Dmitry Safonov , Dmitry Safonov <0x7f454c46@gmail.com>, Hideaki YOSHIFUJI , Leonard Crestez , Salam Noureddine , netdev@vger.kernel.org Subject: [RFC 5/5] net/tcp-md5: Don't send ACK if key (dis)appears Date: Tue, 9 May 2023 23:16:08 +0100 Message-Id: <20230509221608.2569333-6-dima@arista.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230509221608.2569333-1-dima@arista.com> References: <20230509221608.2569333-1-dima@arista.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765457812119724224?= X-GMAIL-MSGID: =?utf-8?q?1765457812119724224?= To mirror RST paranoid checks and tcp_inbound_md5_hash(). Signed-off-by: Dmitry Safonov --- net/ipv4/tcp_ipv4.c | 2 ++ net/ipv6/tcp_ipv6.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index d94cd5e70d58..0c8893240f70 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -918,6 +918,8 @@ static void tcp_v4_send_ack(const struct sock *sk, rep.th.window = htons(win); #ifdef CONFIG_TCP_MD5SIG + if (unlikely(!!key != !!tcp_parse_md5sig_option(th))) + return; if (key) { int offset = (tsecr) ? 3 : 0; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 498dfa194b8b..4131ada9fabf 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -863,6 +863,8 @@ static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 if (tsecr) tot_len += TCPOLEN_TSTAMP_ALIGNED; #ifdef CONFIG_TCP_MD5SIG + if (!rst && unlikely(!!key != !!tcp_parse_md5sig_option(th))) + return; if (key) tot_len += TCPOLEN_MD5SIG_ALIGNED; #endif