Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1889063lql; Wed, 13 Mar 2024 10:56:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3kXNTz9qiMkzmgRPMWoTUFrH85dKKXdPXQbGTj5Cbk0waFjE77WysNsXV66CrO4DFlRNUkm8APDOMeyxNratmAqsCqWp1Lg1ZLsrY5A== X-Google-Smtp-Source: AGHT+IGUdk8Sy880EZaiSIq7c2FE6fHUnbxHmgOra+PJaMv3Y45Afta3B9xSt4FtvqQPN/1KFe1v X-Received: by 2002:a17:90a:d610:b0:29b:c4b7:34fd with SMTP id w16-20020a17090ad61000b0029bc4b734fdmr6485072pju.41.1710352561628; Wed, 13 Mar 2024 10:56:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710352561; cv=pass; d=google.com; s=arc-20160816; b=YpG+1AOe/rZjXqFbRecuFwmuCTSjGZSLx8wKnqrseiG+sGmspt88J3ta0MzZkihcWu 0oUacjOZAqSGTNbjlUYkhrMVe7casarzDM/KhJZKGMNyeFr6dTKOuM6bfJ4UNqgSBZMZ 5gy2U3Ln+TttT+XtuC81H/Z/XNZLUTNbPMhpdtaM083thtZpo69e9HpTU8pNTecY5+cv M59CKKXyl3HXmJSn60XUk9nJDo7mpZayDRhfNnatmKda9kKX7aJoG3J35bDOxsodu0FD k/E8oYkiCGkvUS3b/9dDE6Y2+FEQX9EvzmXv3ELGxZBAkX++mBlfo31JYN22ZLohN2o+ FGXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sB27LBsz/+8bIK4KSw8sYgwbpI/k5roMIkkGcjksv5c=; fh=/DIAl/S4tQsn1UE3RtNxikioLCVegLaO+nGDvsiJckk=; b=RxSw3uuHvX9Om/tC7TeaPiVn8XsNjJbqlwdHU7WR5kc41fjwrp5QL4VxaKPY+dT8r+ XuHZmPtDRazivQrmnXq7Xllg0FjhGuMmP9VvzEEU+TlKBf+vONccy8sBLSllwIhsYdyk qJVmt5t1ig8NPUjuj3ipUhh361qnIO/D+dodxv36CwGtcu8bDmhWnWPJVvcUw2Rqum2A wFPKKdN7jJGQvLaGPnPhdiL9Rf2StPX76LSMmnH8o5FVBMpsOmhKWBNicM08rL+V744k GClsJdWEGlFxu7i7H4kZgwsrB7Hqt75Aw2jznQco2wWyuMrPUv57nKuHR/egdRe/bqeA Ipgg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PLOi4ddw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s8-20020a17090a440800b0029c3714e64csi1774323pjg.177.2024.03.13.10.56.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:56:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PLOi4ddw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-102041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 64097B23362 for ; Wed, 13 Mar 2024 17:44:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5610815279B; Wed, 13 Mar 2024 16:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PLOi4ddw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78AD0151CFA; Wed, 13 Mar 2024 16:47:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348421; cv=none; b=b3cEZx+XYxLEQa521WD4ycozIBmuY1btS53RowVcvIXgwAJCBX6fgre02zNkTNX4zzKJdXAYSt6jWErgUAdnhtsynx5OCvOF+5vqT7RaiHowSZcnpSZe/Xt+YMNa8K6LVm3qsSEhGI1a2Kpdz/UBhAh48KeJQH18xSBPyB8ysq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348421; c=relaxed/simple; bh=npH1Od2uig/VhFoSBdFcsIJP8od1q8NuIXYGucN3FSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c+XjGPiKHf9AN8E49m9oN2madIjbn3xV7ccbU+mm1rcWxj8I1S0TyW0/bkAvIV53Ylajm/hOKPoQx3o3VtNfc+uHkk63vdOLJR7aYJllJny5ZpOO/delDcXm2R/lKWzUxF71PjbwxkaMOEXOPieGCSeZ/zix6BaieUT4UMIolYs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PLOi4ddw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EAFEC433F1; Wed, 13 Mar 2024 16:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348421; bh=npH1Od2uig/VhFoSBdFcsIJP8od1q8NuIXYGucN3FSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLOi4ddw1RlDx/8S38ZXWEhcuLwdiBB3SiBH7/TuDvK/AqQPX1QmC3TCNr57fD7c7 grkXSO86ojnj5co4YMZV1nhf1wPC5LG1qdUSiL7WWXDo5TUPY3zKzR6ZHg1lH/zlkv SygjCdDsrmukxSw7NQwLz7tjGv9VaS5EasiwvREmOyW+k9gqqOnkPkKU6X2xTDj/u0 8ThvqETkgx5OxblXTdbP5JsnREtcD109+0R3+zXjNpWmRX24yQ+xKyPY1khRv5bIXQ LLssd51XgeR4fGdhffp9wv1YfF9zDao90618ESOIlEO9V7wocA6Z99J6RGF1QJiQGs LNht6MIwqRCFA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 16/73] netfilter: nft_ct: fix l3num expectations with inet pseudo family Date: Wed, 13 Mar 2024 12:45:43 -0400 Message-ID: <20240313164640.616049-17-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164640.616049-1-sashal@kernel.org> References: <20240313164640.616049-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.213-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.213-rc1 X-KernelTest-Deadline: 2024-03-15T16:46+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Florian Westphal [ Upstream commit 99993789966a6eb4f1295193dc543686899892d3 ] Following is rejected but should be allowed: table inet t { ct expectation exp1 { [..] l3proto ip Valid combos are: table ip t, l3proto ip table ip6 t, l3proto ip6 table inet t, l3proto ip OR l3proto ip6 Disallow inet pseudeo family, the l3num must be a on-wire protocol known to conntrack. Retain NFPROTO_INET case to make it clear its rejected intentionally rather as oversight. Fixes: 8059918a1377 ("netfilter: nft_ct: sanitize layer 3 and 4 protocol number in custom expectations") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_ct.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index 2b15dbbca98b3..2a8dfa68f6e20 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -1188,14 +1188,13 @@ static int nft_ct_expect_obj_init(const struct nft_ctx *ctx, switch (priv->l3num) { case NFPROTO_IPV4: case NFPROTO_IPV6: - if (priv->l3num != ctx->family) - return -EINVAL; + if (priv->l3num == ctx->family || ctx->family == NFPROTO_INET) + break; - fallthrough; - case NFPROTO_INET: - break; + return -EINVAL; + case NFPROTO_INET: /* tuple.src.l3num supports NFPROTO_IPV4/6 only */ default: - return -EOPNOTSUPP; + return -EAFNOSUPPORT; } priv->l4proto = nla_get_u8(tb[NFTA_CT_EXPECT_L4PROTO]); -- 2.43.0