Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4848782pxj; Wed, 9 Jun 2021 03:27:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE2cUqYgx9YgjqqwgOjqi24TatmJmBOWg+lWT8ZnXD50XENuEKbT+5QW/sCo12GNMYxEiI X-Received: by 2002:a17:906:3da9:: with SMTP id y9mr27738493ejh.303.1623234476540; Wed, 09 Jun 2021 03:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623234476; cv=none; d=google.com; s=arc-20160816; b=A71Sa8Xz2+Sy9fw2xBNqKBGVGmygkGc60oQty09WrXb8lDPquqVmj1Jizu1lsU53NJ nBajmbFNKvQFnWEr1yWp2Jj9qrxo3iCQJmdTOeEDXtWtCAswXT4/tTKSEP1r4c8HgdN2 01QGJUJBvD1thtC0qEmPfcGa8wohZDOiHf2OlVuKX+OpjmdQRGSz7J65E6O5HrwK7h4S bAsxuo7aGDCYW2Zu2xsoSAQ02ii8Llrkt30KCXxNrCmjdEq8mXbDWUsHxuPObLXKfT2k xOmCZIC79ulpn/jFJGXaF40raj/Kclud/3dD1ZpnknMXQHyFL6A+P9aa3FHKmgQ7ayiB BOZg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZaPxYcZkFIdxfSKATo4PFjgax6CGnVmB0eMz0/1NvrM=; b=VtIFxI+YZpzIZu6zjMga7KUOeKG8ovtGY2Cjnm+duf6p59EDbh8Luqt5de5nhmW6Jb E1su6Lp4nkpHezOXBo17mNttfiiOfysmacr/uKoUmPytKfPrk3l1/His8ZuOSsmkumA1 0YZHr8HVNT7XVIZAIe9nBqydZwF06v1fZV7xJR+qN720+kA5noUnMIxZX+laOm+NJc7i DTS03Gc9JypvWcU6xwTxFhlxBr+tgnPTCE3rt2L2WcjQXTxQR0ZcUfQ+Vn1tMFJZJe50 qDrHIAxsZAdaStz6ny13/XciEKB0pXVs1GsD+/z8NJrXXxnB/qyW3RptdBZrLoKOzDqN wD/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BW964WVO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j9si1984178edw.50.2021.06.09.03.27.33; Wed, 09 Jun 2021 03:27:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BW964WVO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235995AbhFHS66 (ORCPT + 99 others); Tue, 8 Jun 2021 14:58:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:49572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236356AbhFHSwJ (ORCPT ); Tue, 8 Jun 2021 14:52:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3868C61432; Tue, 8 Jun 2021 18:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177611; bh=ZZ/7M4Jf4qTjZHlkvSCNJEhhJ75h516yewIVZPSvmx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BW964WVOKeedS/btfEnydTK6I9q4abyjVybCgNPxl6ycA7RembEQsWNCuGIUQ7ALL hOSUFEt06Q2G07bSjEq8EHKCiQrzDC6im38wErvi1vkWQHTKYNK1J/QU46mr3X3eK+ DpXvu1CGYZy1FuXhbVOKtrb4foyAEg+vfuq/a84Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 034/137] netfilter: nft_ct: skip expectations for confirmed conntrack Date: Tue, 8 Jun 2021 20:26:14 +0200 Message-Id: <20210608175943.562222816@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175942.377073879@linuxfoundation.org> References: <20210608175942.377073879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit 1710eb913bdcda3917f44d383c32de6bdabfc836 ] nft_ct_expect_obj_eval() calls nf_ct_ext_add() for a confirmed conntrack entry. However, nf_ct_ext_add() can only be called for !nf_ct_is_confirmed(). [ 1825.349056] WARNING: CPU: 0 PID: 1279 at net/netfilter/nf_conntrack_extend.c:48 nf_ct_xt_add+0x18e/0x1a0 [nf_conntrack] [ 1825.351391] RIP: 0010:nf_ct_ext_add+0x18e/0x1a0 [nf_conntrack] [ 1825.351493] Code: 41 5c 41 5d 41 5e 41 5f c3 41 bc 0a 00 00 00 e9 15 ff ff ff ba 09 00 00 00 31 f6 4c 89 ff e8 69 6c 3d e9 eb 96 45 31 ed eb cd <0f> 0b e9 b1 fe ff ff e8 86 79 14 e9 eb bf 0f 1f 40 00 0f 1f 44 00 [ 1825.351721] RSP: 0018:ffffc90002e1f1e8 EFLAGS: 00010202 [ 1825.351790] RAX: 000000000000000e RBX: ffff88814f5783c0 RCX: ffffffffc0e4f887 [ 1825.351881] RDX: dffffc0000000000 RSI: 0000000000000008 RDI: ffff88814f578440 [ 1825.351971] RBP: 0000000000000000 R08: 0000000000000000 R09: ffff88814f578447 [ 1825.352060] R10: ffffed1029eaf088 R11: 0000000000000001 R12: ffff88814f578440 [ 1825.352150] R13: ffff8882053f3a00 R14: 0000000000000000 R15: 0000000000000a20 [ 1825.352240] FS: 00007f992261c900(0000) GS:ffff889faec00000(0000) knlGS:0000000000000000 [ 1825.352343] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1825.352417] CR2: 000056070a4d1158 CR3: 000000015efe0000 CR4: 0000000000350ee0 [ 1825.352508] Call Trace: [ 1825.352544] nf_ct_helper_ext_add+0x10/0x60 [nf_conntrack] [ 1825.352641] nft_ct_expect_obj_eval+0x1b8/0x1e0 [nft_ct] [ 1825.352716] nft_do_chain+0x232/0x850 [nf_tables] Add the ct helper extension only for unconfirmed conntrack. Skip rule evaluation if the ct helper extension does not exist. Thus, you can only create expectations from the first packet. It should be possible to remove this limitation by adding a new action to attach a generic ct helper to the first packet. Then, use this ct helper extension from follow up packets to create the ct expectation. While at it, add a missing check to skip the template conntrack too and remove check for IPCT_UNTRACK which is implicit to !ct. Fixes: 857b46027d6f ("netfilter: nft_ct: add ct expectations support") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_ct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index a1b0aac46e9e..70d46e0bbf06 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -1218,7 +1218,7 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj, struct nf_conn *ct; ct = nf_ct_get(pkt->skb, &ctinfo); - if (!ct || ctinfo == IP_CT_UNTRACKED) { + if (!ct || nf_ct_is_confirmed(ct) || nf_ct_is_template(ct)) { regs->verdict.code = NFT_BREAK; return; } -- 2.30.2