Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5F6F347010C; Tue, 21 Jul 2026 19:12:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661128; cv=none; b=mF3/1lk0gXeKzA6i6Yj8FnZWD1WU0CqZk82s0ecZ6QOQ7F0nYt7HaCdZa/C+gZgiOXeBx6OXz47l1yCYmZBly4SSIQVUmeiNmx2UaDHK0T3jcTDOedxOPmSKVJ7qfehNQqLTYmxViACmY1n+aqXKP7SO4IjK/TKI0b2oS0h1NpA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661128; c=relaxed/simple; bh=3fGX/QcMTezU1vBrko+AXC5vG3rEsyQhkYSRdFJB5R4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XiY2bVMTdGrNP7Z+0CtAmPPNHztpLVMGyvYC9TJob4pDXvG6GHJjgzDzjQSSioREjKNctZ6gEFaceCz3qPqOuIvhR0mTCpR+OXjU3ym04AlcGYWDjIpk+YbHpli/wpxofvJrBBPL2Cr18+mXiIFERnrg78BstGHSoZKd2Tqk+Do= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PMkU2Wc1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="PMkU2Wc1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB0071F000E9; Tue, 21 Jul 2026 19:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784661127; bh=SiRHeLNRdUTqv/nbVw1QRoRBT6fKnnVg0LHmdA3rxPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PMkU2Wc1VgMPa1JskCOAzLgxKMKBlglNj3U4o5AdU7GOKlPohGjhPrjY3u6kywbEz URTc5fTePLwqDjTqxD3yy18sNpXQSRLKBWo75mNqPEUZZwAtSjPZA0rgM6tLGRPpdG aZISdOtBaqoiW/EsZ+7beXv51EZGzg2I3STZzXJg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 7.1 1239/2077] netfilter: nf_conntrack_helper: cap maximum number of expectation at helper registration Date: Tue, 21 Jul 2026 17:15:12 +0200 Message-ID: <20260721152622.036195159@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pablo Neira Ayuso [ Upstream commit 397c8300972f6e1486fd1afd99a044648a401cd5 ] On helper registration, the maximum number of expectations cannot go over NF_CT_EXPECT_MAX_CNT (255), but zero can be specified then nf_conntrack_expect_max applies. Turn zero into NF_CT_EXPECT_MAX_CNT otherwise, expectation LRU eviction on insertion is disabled. Moreover, expand this sanity check all expectation classes. This max_expecy policy is only tunable since userspace helpers are available, set Fixes: tag to the commit that adds such infrastructure. Remove the check for p->max_expected given this field must always be non-zero after this patch. Fixes: 12f7a505331e ("netfilter: add user-space connection tracking helper infrastructure") Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_expect.c | 3 +-- net/netfilter/nf_conntrack_helper.c | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index 113bb1cb1683fd..38630c5e006f08 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c @@ -496,8 +496,7 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect, lockdep_is_held(&nf_conntrack_expect_lock)); if (helper) { p = &helper->expect_policy[expect->class]; - if (p->max_expected && - master_help->expecting[expect->class] >= p->max_expected) + if (master_help->expecting[expect->class] >= p->max_expected) evict_oldest_expect(master_help, expect, p); } else { const struct nf_conntrack_expect_policy default_exp_policy = { diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c index ec0aafcb198518..d1392b8e09af89 100644 --- a/net/netfilter/nf_conntrack_helper.c +++ b/net/netfilter/nf_conntrack_helper.c @@ -377,8 +377,13 @@ int __nf_conntrack_helper_register(struct nf_conntrack_helper *me) if (!nf_ct_helper_hash) return -ENOENT; - if (me->expect_policy->max_expected > NF_CT_EXPECT_MAX_CNT) - return -EINVAL; + for (i = 0; i <= me->expect_class_max; i++) { + if (!me->expect_policy[i].max_expected) + me->expect_policy[i].max_expected = NF_CT_EXPECT_MAX_CNT; + + if (me->expect_policy[i].max_expected > NF_CT_EXPECT_MAX_CNT) + return -EINVAL; + } mutex_lock(&nf_ct_helper_mutex); for (i = 0; i < nf_ct_helper_hsize; i++) { -- 2.53.0