Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1288672rwi; Thu, 27 Oct 2022 13:51:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4dIDOWSG+7hrF7N0503/pBaxbnyDYvhxG7bDjjsePXWddUS9ed6iymo9pH0pGQWBDaE+f+ X-Received: by 2002:a17:906:5dae:b0:78e:302f:4218 with SMTP id n14-20020a1709065dae00b0078e302f4218mr45689130ejv.22.1666903905508; Thu, 27 Oct 2022 13:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666903905; cv=none; d=google.com; s=arc-20160816; b=Jf6Kqx/mjVTGRM7cGP+4l1oz3vWKJoBnBeAgKgICrqwqVD/qLQAc8+hDRUxRTyLZoM HgLB1d027WfQgVx6vV/qeCWieSiG+d45GA3m7eP6seJ6zpXOapjdkoV8JJWWOMrZfsoy 4jfL0pe4P+WkXZbCnXFfoR7Mck0LifCNMSHU8abi5DGkHq68jTj2oOXYOzwlAYROMCxH qV+OLUD8FTqCJYDX5MvkNI5UctgUXTQx2+AXzXcyphXScFMX2tkU4LhH/hhrJtM65XCI JH7nuqrXVJZJJWJRJrCJKOqRZAMjdv9t6/9JglhdkxFJr0NmBzcsArMbcXrOs+2y9Wdw bLKA== 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=MoGdmlHHpEUPuXthWjW8u1iP64OMQnsBPTKyfVuhzXI=; b=EgBMVLBQtPbSgUYuunvHxjqcP0jbaURiwGLJY/wbI/P0cGWoEguZQ3PZrfd5utiXAs F6/heQ8GO5hqmLbBbcYB4P5O9GFpWJq9vy7kVRwB6MhQnRnUNm6BIQsqfwfnce2Nx+g9 7aMoDayQAGNsyKm+gzvYwtYKUr7PI2b2irzN4luG0p+ZORS4/RylcY/GST3tUQToaaER Rwj/iNSVmwOZ5kvHOu/WtIdzAMk4VGkBAY099bXFrv6Hy4R7osYwVikVrn7K6Q3ipl2K haYj2hmYNd1/Kx+TTt2IqQSMGcuPO90R5e6kRIuhdLmwRcijsuWVu1xUQlZPyTJBnPzk 0lmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=google header.b=gSAoOgAv; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd33-20020a17090762a100b0078dc7f7d0ebsi780888ejc.822.2022.10.27.13.51.21; Thu, 27 Oct 2022 13:51:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=gSAoOgAv; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S237148AbiJ0Uur (ORCPT + 99 others); Thu, 27 Oct 2022 16:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237154AbiJ0Usq (ORCPT ); Thu, 27 Oct 2022 16:48:46 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB61167E6 for ; Thu, 27 Oct 2022 13:44:48 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id w14so4155815wru.8 for ; Thu, 27 Oct 2022 13:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; 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=MoGdmlHHpEUPuXthWjW8u1iP64OMQnsBPTKyfVuhzXI=; b=gSAoOgAv2U5kJtyYr7yDdRnMNeIyd8FzGikQ98Di2J6T1ItIL6ZS7GHQKzHKdPPYKd +8ruIARt0FKlU/ZUA3yWYh5WA5tb5Ewekp8C6bFUOTRHypdAcBI4RNf5z1duywraGfQc +znM2TcBP5AMUY+8iu94mJECQWwO7BeRw20D3ywcHjHkECx3pz9e7GMpwln4EgzTlSPu X4m6PFwa7d/J+znya2T3k/IxWaPAeZ8v9NfmbuBL04iSsWxQsFzNeEDveG4N1YBubKte IP0+9DtaAt6hKJxAyxfOrKY4qVMoYPwfqA+s8SDg/kH6chE6FYJaj0WP9Jzn3aJGFl+2 F7pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=MoGdmlHHpEUPuXthWjW8u1iP64OMQnsBPTKyfVuhzXI=; b=d32SE9ofZmCrFjoDTj4pxhzF/B5UtcLQELOLVCvhMMkw68oCkqsGM1kaqK/iLl/wq0 Ta9z63n8HknULTDuUJ6PnXyKia8qKgQHuhW/TJzPwflwbbq45y5d0+XOAyiZr/OArxZp nJYZpnowmWohVOWrWoAeO14xFsNBXj+AqloeTXTrDZgPGwnH9ju4UbFMCcpNp9RiXyAX kCMwWz0H5ViMxIqboVx869c3knjdQRv+0bRgvvE70FqvZ7fFMvqh2iENY/iQZyQyrBlh njHV44ANVdVuRkF3Ah7XPWUHT3g5kchZYo8qoOHHydEa6Ns8idh9+vYYCPwEC6EpKQ/d CxQA== X-Gm-Message-State: ACrzQf1ZqCKoUylPAy8m69pNFvJdVGZnvVgERY68RQtrkJv9clXBKNub AgvGsQ4Kyb6G2Slxkk/PLp0VlQ== X-Received: by 2002:adf:e64e:0:b0:236:76a9:446 with SMTP id b14-20020adfe64e000000b0023676a90446mr14065104wrn.696.1666903468407; Thu, 27 Oct 2022 13:44:28 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id n3-20020a5d6b83000000b00236644228besm1968739wrx.40.2022.10.27.13.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 13:44:27 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org, David Ahern , Eric Dumazet Cc: Dmitry Safonov , Andy Lutomirski , Ard Biesheuvel , Bob Gilligan , Dan Carpenter , "David S. Miller" , Dmitry Safonov <0x7f454c46@gmail.com>, Eric Biggers , "Eric W. Biederman" , Francesco Ruggeri , Herbert Xu , Hideaki YOSHIFUJI , Ivan Delalande , Jakub Kicinski , Leonard Crestez , Paolo Abeni , Salam Noureddine , Shuah Khan , netdev@vger.kernel.org, linux-crypto@vger.kernel.org Subject: [PATCH v3 22/36] net/tcp: Add option for TCP-AO to (not) hash header Date: Thu, 27 Oct 2022 21:43:33 +0100 Message-Id: <20221027204347.529913-23-dima@arista.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221027204347.529913-1-dima@arista.com> References: <20221027204347.529913-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 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 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-crypto@vger.kernel.org Provide setsockopt() key flag that makes TCP-AO exclude hashing TCP header for peers that match the key. This is needed for interraction with middleboxes that may change TCP options, see RFC5925 (9.2). Co-developed-by: Francesco Ruggeri Signed-off-by: Francesco Ruggeri Co-developed-by: Salam Noureddine Signed-off-by: Salam Noureddine Signed-off-by: Dmitry Safonov --- include/uapi/linux/tcp.h | 2 ++ net/ipv4/tcp_ao.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h index 508bedbc6ad8..b60933ee2a27 100644 --- a/include/uapi/linux/tcp.h +++ b/include/uapi/linux/tcp.h @@ -347,6 +347,8 @@ struct tcp_diag_md5sig { #define TCP_AO_MAXKEYLEN 80 +#define TCP_AO_KEYF_EXCLUDE_OPT (1 << 0) + #define TCP_AO_CMDF_CURR (1 << 0) /* Only checks field sndid */ #define TCP_AO_CMDF_NEXT (1 << 1) /* Only checks field rcvid */ #define TCP_AO_CMDF_ACCEPT_ICMP (1 << 2) /* Accept incoming ICMPs */ diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c index e5b4e9f1e83e..90b864d4ee7d 100644 --- a/net/ipv4/tcp_ao.c +++ b/net/ipv4/tcp_ao.c @@ -604,7 +604,8 @@ int tcp_ao_hash_hdr(unsigned short int family, char *ao_hash, WARN_ON_ONCE(1); goto clear_hash; } - if (tcp_ao_hash_header(&hp, th, false, + if (tcp_ao_hash_header(&hp, th, + !!(key->keyflags & TCP_AO_KEYF_EXCLUDE_OPT), ao_hash, hash_offset, tcp_ao_maclen(key))) goto clear_hash; ahash_request_set_crypt(hp.req, NULL, ao_hash, 0); @@ -646,7 +647,8 @@ int tcp_ao_hash_skb(unsigned short int family, goto clear_hash; if (tcp_ao_hash_pseudoheader(family, sk, skb, &hp, skb->len)) goto clear_hash; - if (tcp_ao_hash_header(&hp, th, false, + if (tcp_ao_hash_header(&hp, th, + !!(key->keyflags & TCP_AO_KEYF_EXCLUDE_OPT), ao_hash, hash_offset, tcp_ao_maclen(key))) goto clear_hash; if (tcp_ao_hash_skb_data(&hp, skb, th->doff << 2)) @@ -1497,7 +1499,7 @@ static inline bool tcp_ao_mkt_overlap_v6(struct tcp_ao *cmd, } #endif -#define TCP_AO_KEYF_ALL (0) +#define TCP_AO_KEYF_ALL (TCP_AO_KEYF_EXCLUDE_OPT) #define TCP_AO_CMDF_ADDMOD_VALID \ (TCP_AO_CMDF_CURR | TCP_AO_CMDF_NEXT | TCP_AO_CMDF_ACCEPT_ICMP) #define TCP_AO_CMDF_DEL_VALID \ -- 2.38.1