Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (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 E79A91115 for ; Fri, 1 Mar 2024 12:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.245.30 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709297010; cv=none; b=l+totmJeNhMLijB2FaQ/xULWW3eBYpBitCfwuRM9m+17UauIQLBJ3QxINaa7ppI6P/XByIY2ZZDzbKnfNRTpaWufBbfAiLlxfOPA5Kq+OkUZ/2HMl6Nra3jUsxbph5wuzWcG0DPKFjGoV76ZRM82kJeoxt+8I1wbqoil7hSuCzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709297010; c=relaxed/simple; bh=ChJ14kvk+08oAEt5mgOaXBTpR2+D72mdj7hx24/eyKU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cQtW4a/cVZfGqVtFjO4y0Fm8fsxCQn9xNUVbf1JggsiBEhexMuHshqlLztgj9/qFsE1Q76IQS/Z/vXnMzqR/f/g0OR4L7FgHlWcHmiYq6xaaqH4k7SBeY0y5pPbvnB5EkNY42nNJlOiXQAgWF56RtZV0Y0fOQlJ3EI1HW40aZtw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de; spf=pass smtp.mailfrom=breakpoint.cc; arc=none smtp.client-ip=91.216.245.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=breakpoint.cc Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1rg2EX-0002F2-Nn; Fri, 01 Mar 2024 13:43:25 +0100 From: Florian Westphal To: Cc: Florian Westphal Subject: [PATCH nf v2] netfilter: nft_ct: fix l3num expectations with inet pseudo family Date: Fri, 1 Mar 2024 13:38:15 +0100 Message-ID: <20240301123820.17664-1-fw@strlen.de> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- v2: prefer EAFNOSUPPORT (Pablo Neira) 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 bfd3e5a14dab..255640013ab8 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -1256,14 +1256,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