From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796379037; b=zizJ1e1fICArEnL84r7hNXcZN7Es3M9n6LE9JbW7zdSFQ+M60cMzt26TpkOhSukkZ0Ty 8Een7aJJFRIrb1sIW6g4VuX+b9j3lmm4Q5XG43Aq86j1xO8kiBBukZ6NQdsLO8+mysIBV 9KcDvuey2jWBYFbFiZ5EcJrg82mYktJhDyulxltW8MEH3xdUZXAyYfw9pCSTQmgelKGnI lSvBVwIGis3bTct6jco0SuARNpGW5SQ2MjVTP8Lf8wcsKvrZvLa/HB2rjuW16p1ZIS3bW OOJ+/+vNVtYzslAnN1BD9NjHHv0f6/4nGGoGnKjx4aHwN6IV9gfNmMt+HW48RGiEyyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379037; 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=jM7oDIUq9kmlnczHMn6+JMFFHemcp1+lsuEO6D+nKRo=; b=mmHOh+9tRtjCHceX/Ri6ywH2zYqeLJc7ht1NDp+/Jkecmn3g3pDnXyKdoA9uw8x3PsK9 X8dst6eQ0zZEyVKoRQLqU58ltXJaCt3QYBSClOo0GnNr1CrEBfWaYir/toDD9Bdt4tJtm MRGSgC01DxS7AuBZqy0QaKLPg85DZKgsVkF0t8UXXp9p9k/5+44mEYpvWMPmGrZubazmi lH2SMwhOJ1n7xVGW3EQXHFDuyLDSU/huQ+Zp8+PlhX0rIZhWaqJU/F1/v18tD9v5otLwj GNZdtdWLbA3VKDgY0Fs8oynCVbS4fvOpCwZRKXdh5gOuYk16GogPJJCtYVYqJHvYIxQ== 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=KxpHduYe; 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 0C50E606A330; Fri, 4 Dec 2026 10:10:36 +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=KxpHduYe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AC0C1F000C2; Fri, 4 Dec 2026 10:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379036; bh=jM7oDIUq9kmlnczHMn6+JMFFHemcp1+lsuEO6D+nKRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KxpHduYeqy/ZPKgKtzwSLGgnlCeFLFEx7aiER1Wt42EoYPxHnPTKDmvyPh1JgK9W/ qD3S9n1iZgfZOiKO8xq3pf+IfmNvCXyGjUWklH2Li/pO3SsJl857/YH/TT3/HzunzJ Lbdk3xqXjdrmjSjDXMxtniymmMJtSQbJHOSS94nw= 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.1 0002/1059] netfilter: nft_ct: expectation timeouts are passed in milliseconds Date: Fri, 4 Dec 2026 18:52:13 +0900 Message-ID: <20261204100644.054569050@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 f789c6c8f146b..fbe83e879654e 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -1229,11 +1229,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] || @@ -1269,8 +1281,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); @@ -1290,7 +1305,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; @@ -1340,7 +1355,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