Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3211850iog; Mon, 27 Jun 2022 11:32:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sf+wJ8VHNADAnIBvIfSczQL/HxxN/EUxUdicr+EOS02HVQfQufpmBV17N1zS0HvWxzQ8tu X-Received: by 2002:a17:90a:17a6:b0:1ec:74e4:d7a3 with SMTP id q35-20020a17090a17a600b001ec74e4d7a3mr22789122pja.115.1656354735073; Mon, 27 Jun 2022 11:32:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656354735; cv=none; d=google.com; s=arc-20160816; b=y4iBBhxi6xP4yqbGpNSgSoUj3A7Qps4YjGAWEt+OOY1W11gTXi2r5ep/ryxVUYGN/J QP33Dcv/nCJPd+1nplSnrB927Bc8SrE2hkfeqPxKAcXn0dZnvD4qVuN1+B/XTED0d23k 6VuxjQHBv7dhVoI4QpVtY0RdsGhXrX7WGIy1u5qKXnFNX7kdbJh9okjVArjANz7jRJrT BC10QDoTPIYaPE0z3q+uRKl58MhgvFJ/zq1e9eDR0SSt2adt1DxKP1lJD09usDAtn7kg pZuUj7WJg7HFFPuml4WplKcni/ATNBTkOUnNQIm8tsY2vw35un3yJBbR3lPFErodgWbT ChvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3jcAWDefc535O2YMy/ioMKmHqqkutnscR3vy7uDOQM8=; b=WmJItr1WXg3lw4KaKX+wvNhF0jm6OXj5FBsXhQq6NSW2mrkHXEZqrE7adqXLh3C9B0 Pz0hC+AD87J2Ok+61FIqadtX5eLZiWVZ1aLjQXcccKGiLjzJytcCMRPWL4ozFJxXHSFp s26Za10ydJGggeVjT/9v7YSgNlSPzGuchzPtRzdQqgG7oLT03RDHBB8EsLtslqK/eEol oHop/8czkC1rcMQ7eM+zweGTRPbBzF1yGE1aIuVOdQSlWGMB8/kA/weF1eVOsdf91gJs 14d3zR8LisE1GdPaJkdDTVwtNj3ttOseZRIqok+k7UbgQVgyA6TkJo3yCvJNgbZIOFB3 Hhzg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k20-20020a056a00135400b004fa3a8e003fsi14857195pfu.246.2022.06.27.11.31.59; Mon, 27 Jun 2022 11:32:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239288AbiF0RWN (ORCPT + 99 others); Mon, 27 Jun 2022 13:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234714AbiF0RWJ (ORCPT ); Mon, 27 Jun 2022 13:22:09 -0400 Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 907CBE083; Mon, 27 Jun 2022 10:22:08 -0700 (PDT) Date: Mon, 27 Jun 2022 19:22:05 +0200 From: Pablo Neira Ayuso To: Wei Han Cc: kadlec@netfilter.org, fw@strlen.de, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] netfilter: xt_esp: add support for ESP match in NAT Traversal Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Fri, Jun 24, 2022 at 08:05:30PM +0800, Wei Han wrote: > On Thu, Jun 23, 2022 at 09:36:41PM +0200, Pablo Neira Ayuso wrote: [...] > > > + } else { > > > + return false; > > > + } > > > + } else if (proto == IPPROTO_ESP) { > > > + //not NAT-T > > > + eh = skb_header_pointer(skb, par->thoff, sizeof(_esp), &_esp); > > > + if (!eh) { > > > + /* We've been asked to examine this packet, and we > > > + * can't. Hence, no choice but to drop. > > > + */ > > > + pr_debug("Dropping evil ESP tinygram.\n"); > > > + par->hotdrop = true; > > > + return false; > > > + } > > > > This is loose, the user does not have a way to restrict to either > > ESP over UDP or native ESP. I don't think this is going to look nice > > from iptables syntax perspective to restrict either one or another > > mode. > > > This match original purpose is check the ESP packet's SPI value, so I > think the user maybe not need to pay attention that the packet is > ESP over UDP or native ESP just get SPI and check it, this patch is > only want to add support for get SPI in ESP over UDP.And the iptables rules like: > "iptables -A INPUT -m esp --espspi 0x12345678 -j ACCEPT" This rule would be now allowing UDP traffic to go through, even if the user does not need it. An explicit policy entry to allow NAT-T would be preferred. There is another issue, although I suppose there is a standard UDP port for this, user might decide to select a different one, in that case, this would break. And I don't see an easy way to allow user to select the UDP port in the iptables case.