Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795620730; b=2LQghlUCAsesLZqAvZXsrZ57m8c47luGPZiRFZaTnOVumxXBI+RXMa0szL+x11teiiuT L92fKgF3jmh1ju/Nm5O9r6KgxkM+jHVzD8dF9lvXdHHKI3xnjFuRAdzrG9U8vBWs20pQt KwHGm3nvP4wazI+CaDM4w0IS6WVDd5Og9Wyp4CsmJDSeoN845WHDtz4o2Wkvxz6Htcs4Z SF24LfPWusBHEathrd/8mJ8evw0NYIZPfMifjfSF4jgSb72unD8xw7X25aWKbh/QTjhju HBnEXyFjDEdmFWD5YJmpCJVlHMoV3PD1IZN0Yb5RpDWWDT2pNnWYyPOmqINX6ISDVRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795620730; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=dLelQTSNLTLCRsMuBS9ng5nUiDn/jUbRuAwidta/Cj8=; b=PrQzsmUW3DM7/vVyWo3fG0opd7fB56ODhi2/lY1BpfJYhQ5Oqm9b/KtcgmW/5+AaPxAi PIimndHc7+8gsyiPJboL7bbMOYowrdZhN650WFq5rj3/6aDplEF6zuAhz7PwG817okx9y +XeAM8s+MO/jU0nViBvm+lhjiL6teDSNx7WdO3MANGa/b3FF5iwkM65TuBrGzzVoMGhM/ lF17fGpt4iZAHVhWlLZZ5cyqHb6xYCTBzu3TvgJZcCN9ZPxDzleP5Aal3VxWqeuheWjw2 k78nOuiKnCEWsLNtB7eQUzsjFZegeUWU3x0NByYrGYSRWPrmjjBzNOyn7PdYoG1rMGg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dLdQmmUW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2379C606A326; Wed, 25 Nov 2026 15:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dLdQmmUW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76AFF1F000C4; Wed, 25 Nov 2026 15:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795620730; bh=dLelQTSNLTLCRsMuBS9ng5nUiDn/jUbRuAwidta/Cj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dLdQmmUWBO9o6Rzw58Wbh38jEIdA5NjengypfMMI/RfE/+sJsAcs4QTwMifbPj1cJ 65O65Urg5H29ueDRK8S1gz9zQ8cRzFQEdwZKAr6fmu83CW16mT73k2KurhOwHqIuvI cuwL2ovTM80qqpKayhxEsv7H73FPpVGNO5HGOc9I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Florian Westphal , Pablo Neira Ayuso , Mark Bundschuh , Sasha Levin Subject: [PATCH 6.18 001/990] netfilter: nft_ct: expectation timeouts are passed in milliseconds Date: Wed, 25 Nov 2026 15:22:48 +0100 Message-ID: <20261125143822.114872496@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143822.072087159@linuxfoundation.org> References: <20261125143822.072087159@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit 6fb421bd07f156cdf0cdede062d31f1c21def326 ] Userspace passes '5000' in case user asks for 5 seconds. Allowing for sub-second expectation lifetimes makes sense to me. so fix up the kernel side instead of munging nft to send a value rounded up to next second. Also note that this violates nft convention of passing integers in network byte order, but we can't change this anymore. Fixes: 857b46027d6f ("netfilter: nft_ct: add ct expectations support") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Stable-dep-of: 3679da4ad8be ("netfilter: nft_ct: move custom expectation support to helper") Signed-off-by: Mark Bundschuh Signed-off-by: Sasha Levin --- net/netfilter/nft_ct.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index 11d99778216f1..4687fc244eaf9 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -1217,11 +1217,23 @@ struct nft_ct_expect_obj { u32 timeout; }; +static int nft_ct_expect_timeout_get(const struct nlattr *attr, u32 *val) +{ + unsigned long jiffies_val = msecs_to_jiffies(nla_get_u32(attr)); + + if (jiffies_val > UINT_MAX) + return -ERANGE; + + *val = jiffies_val; + return 0; +} + static int nft_ct_expect_obj_init(const struct nft_ctx *ctx, const struct nlattr * const tb[], struct nft_object *obj) { struct nft_ct_expect_obj *priv = nft_obj_data(obj); + int err; if (!tb[NFTA_CT_EXPECT_L4PROTO] || !tb[NFTA_CT_EXPECT_DPORT] || @@ -1257,8 +1269,11 @@ static int nft_ct_expect_obj_init(const struct nft_ctx *ctx, return -EOPNOTSUPP; } + err = nft_ct_expect_timeout_get(tb[NFTA_CT_EXPECT_TIMEOUT], &priv->timeout); + if (err) + return err; + priv->dport = nla_get_be16(tb[NFTA_CT_EXPECT_DPORT]); - priv->timeout = nla_get_u32(tb[NFTA_CT_EXPECT_TIMEOUT]); priv->size = nla_get_u8(tb[NFTA_CT_EXPECT_SIZE]); return nf_ct_netns_get(ctx->net, ctx->family); @@ -1278,7 +1293,7 @@ static int nft_ct_expect_obj_dump(struct sk_buff *skb, if (nla_put_be16(skb, NFTA_CT_EXPECT_L3PROTO, htons(priv->l3num)) || nla_put_u8(skb, NFTA_CT_EXPECT_L4PROTO, priv->l4proto) || nla_put_be16(skb, NFTA_CT_EXPECT_DPORT, priv->dport) || - nla_put_u32(skb, NFTA_CT_EXPECT_TIMEOUT, priv->timeout) || + nla_put_u32(skb, NFTA_CT_EXPECT_TIMEOUT, jiffies_to_msecs(priv->timeout)) || nla_put_u8(skb, NFTA_CT_EXPECT_SIZE, priv->size)) return -1; @@ -1328,7 +1343,7 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj, &ct->tuplehash[!dir].tuple.src.u3, &ct->tuplehash[!dir].tuple.dst.u3, priv->l4proto, NULL, &priv->dport); - exp->timeout += priv->timeout * HZ; + exp->timeout += priv->timeout; if (nf_ct_expect_related(exp, 0) != 0) regs->verdict.code = NF_DROP; -- 2.53.0