Article View: linux.kernel.netdev
Article #10863[PATCH net 1/2] netfilter: conntrack: avoid secs-to-jiffies overflow in SIP helper
From: luoqing
Date: Wed, 04 Nov 2026 08:59
Date: Wed, 04 Nov 2026 08:59
67 lines
11211 bytes
11211 bytes
From: Qing Luo <luoqing@kylinos.cn>
refresh_signalling_expectation() converts the expiry from a SIP
REGISTER 2xx response with "expires * HZ" in 32-bit arithmetic and
stores it in a u32. sip_strtouint() only rejects values above
UINT_MAX, so the answering registrar controls the input.
Expectations are reaped with "(__s32)(exp->timeout - nfct_time_stamp)
<= 0". At HZ=1000 an expiry of 2147484 seconds (24.9 days) crosses
2^31 and the expectation is born expired, while 4294968 seconds wraps
to 704 jiffies. Registration refreshes break, or a signalling
expectation stays pinned for days.
Add nf_ct_secs_to_jiffies(), which multiplies in u64 and saturates at
INT_MAX so the signed expiry test stays positive, and use it for the
SIP expectation refresh.
Sweeping all 2^32-1 inputs at HZ=1000, the helper never wraps, never
yields a value that reads as expired, and matches the old expression
up to INT_MAX / HZ.
Fixes: 0f32a40fc91a ("[NETFILTER]: nf_conntrack_sip: create signalling expectations")
Cc: stable@vger.kernel.org
Signed-off-by: Qing Luo <luoqing@kylinos.cn>
---
include/net/netfilter/nf_conntrack.h | 10 ++++++++++
net/netfilter/nf_conntrack_sip.c | 3 ++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index c39425e54d87..b32716084ea8 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -210,6 +210,16 @@ bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff,
void __nf_ct_refresh_acct(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
u32 extra_jiffies, unsigned int bytes);
+/* Convert a timeout in seconds to jiffies, saturating at INT_MAX instead of
+ * wrapping the "secs * HZ" product in u32.
+ */
+static inline u32 nf_ct_secs_to_jiffies(u32 secs)
+{
+ u64 delta = (u64)secs * HZ;
+
+ return delta > INT_MAX ? INT_MAX : (u32)delta;
+}
+
/* Refresh conntrack for this many jiffies and do accounting */
static inline void nf_ct_refresh_acct(struct nf_conn *ct,
enum ip_conntrack_info ctinfo,
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 64bc440b1181..e2fd97f53386 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -891,7 +891,8 @@ static int refresh_signalling_expectation(struct nf_conn *ct,
exp->tuple.dst.protonum != proto ||
exp->tuple.dst.u.udp.port != port)
continue;
- WRITE_ONCE(exp->timeout, nfct_time_stamp + (expires * HZ));
+ WRITE_ONCE(exp->timeout,
+ nfct_time_stamp + nf_ct_secs_to_jiffies(expires));
WRITE_ONCE(exp->flags, exp->flags & ~NF_CT_EXPECT_INACTIVE);
found = 1;
break;
--
2.25.1
Technical Details
Message-ID:
<20261104085925.773471-1-l1138897701@163.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356294-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-356294-linux-kernel-netdev=dewy.ru From: l1138897701@163.com (luoqing) Newsgroups: linux.kernel.netdev Subject: [PATCH net 1/2] netfilter: conntrack: avoid secs-to-jiffies overflow in SIP helper Date: Wed, 4 Nov 2026 16:59:24 +0800 Organization: Usenet Network Message-ID: <20261104085925.773471-1-l1138897701@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3357581"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:XUXZbTXuNKIyzOgkHcrJ20Q2C1w= sha256:E1IrNW/JWRXfh0g0C7AUQ7LBTOpsrkWbMKD8uH3W6L0= sha1:4d3FXAwyZgFyC//3GnwvRr48h40= sha256:ErLKUPaRfqlbYS/Uyj2kc17t4rFwmPiBB3HatuGU07A= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 9953F112B44; Wed, 4 Nov 2026 12:05:41 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.048 X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q7gkluxfzs_H; Wed, 4 Nov 2026 12:05:37 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-356294-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 3D1C8112B41; Wed, 4 Nov 2026 12:05:28 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 3E57D2739A; Wed, 4 Nov 2026 09:00:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793782845; b=djob3Gw2UJbcSert8t/vKqqQB4AeA4QU9bYci9LZE7ju0yvGOaXbIHdYUhpLfcjX+orv QOTHTofrgV+t/2PwpUtyZ6SwJ/xtnjPynzXMIIxcdyrDWMwdcxAvu1z0R+qPnEd5cePXh paFhZfKLgkz1/CvWY6LghED3qTaNK/jOjrJ+0n00EMP39fFOHNKu9muE++dc0Yx/lBwMG WkBiM2w1NKxjeWKX2YdoyEp5LM7EqKCpHcw/rXp75yHlcrfTgBMpl7BlOUBPY1Qk2l3bq 1Ro5Y2N9IeUjKMP/ty5SAYJmZbS5+CupZF3dqwcvVK10bTg2ptEcMGd7VUHAV4dHe7g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793782845; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=vtX9eU8J3Lmk3qBwxV4wOykn6nF9IeBVyI8Jpue03zQ=; b=tMikgALS+Qc+IkvSliyCQeYov+OIbLjiMid9WQNp1bA9mc/hz7ra/nQO4GEarOI1rdye qGPZ+2GysEL3CSWaVogg3X2hrZzozTDwgWKjRrgb5/M8kS7nd9F+sCFnxLDgML1Zmv22z Irf+qp8w2k1Wz6Cj1cL8/QuhCPXPciXBkhdWfIgTlMdBlpg1c27vQ+9j73tYYqhIkbQ0q jL1MxpO3W0H5Rhdk8RNzCX5hqSI2XvvfleMSZggwPw4bGg4BeHejrecPO7dd8ZPgecqPs f8O1BdqNfaRNrYMQuPDRS1wUiniFjQlRfDygWaDvzcV2MTAFN+/PDcgHQSQDwNH4K3g== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Z8N3njDk; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15E0C606D806; Wed, 4 Nov 2026 09:00:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Z8N3njDk X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.2 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793782839; b=5FcY0UcmvFDbi9MwyNigm9Gx7fTdAZbEXofy+ue8jLloCoITZU+jyyiW2t7Wavkjnkcr F7dO7KXtRJ8grbrs6MrxIM4N5M2EDiWmk01ZDpb5jQIo/xeUcOEhoUqccPcd/RoAJQ7/a 23HqzzbAcldKXqWSGAVyPcWRTVFmkHoOJUepvYp+yxHJvhXZCRVaFYjCrtvARxGNksRvr 4CxlvsXwWz1NpKSRQOz5T/hBU9r/ZxNinBhzJKA7b8VnWuXq3cz3Twrf9j5m1mN9g49G6 1ylky73AEyDw8+jfuj4brs/ad1IAzx7KFe1/t6bcDiBM1mguRm1YbPRZ22Jp1NNkR9A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793782839; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=vtX9eU8J3Lmk3qBwxV4wOykn6nF9IeBVyI8Jpue03zQ=; b=LX+JpXcLHS9U8rWQTdwQY3gmneaIhAjbw/21lj4uNw1er2U8vyHUyS2sYl/6plPzXHGo kiGyIvt6xV2Nlw5wQdfbPe1Ne73fea/ICiNf4lg6/jU5fu213vUiHgFltKTRwd1Ry6Yc3 LiciwwaVK3aoG/bmrXDeukFt9VYmsbT53Voj4WQ8124vgBSO1FKhRXflmm/a6OFbuIyhq s9j4nywSJR9PFATBfdhpVqp74aaOPycjSloijXL7bJ+WrE/FMgxmmhCKU5vy25nV1b+iS 7WyZwI6JZHHdD3yx/FRM/XyTgJ7MV6tR+47bhL4C66VDhwrIQNwQbKCLE26+EVOci4Q== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=Z8N3njDk; arc=none smtp.remote-ip=220.197.31.2 X-Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E54CD606A328; Wed, 4 Nov 2026 09:00:35 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E54CD606A328 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=vt X9eU8J3Lmk3qBwxV4wOykn6nF9IeBVyI8Jpue03zQ=; b=Z8N3njDkiP2htBS7bb wriQDgLiqr4BvEkFrWDySTYVRO+98VECIHKn+p8egmdEiZbBY9JgcC4gdcEzaHwl +VMLq884eeIQUUumMe9xE5Rx+lIRqiofZLj5KS1l/UenaTXMTdnP6p2KtjTsL45q bSr3ndJDwBOyJYYDgquZmZWGw= X-Received: from localhost.localdomain (unknown []) by gzsmtp4 (Coremail) with SMTP id PygvCgB3LJju8+pqEDm4Dw--.32829S2; Wed, 04 Nov 2026 16:59:27 +0800 (CST) X-Cc: Phil Sutter <phil@nwl.cc>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Patrick McHardy <kaber@trash.net>, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: git-send-email 2.25.1 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-CM-TRANSID: PygvCgB3LJju8+pqEDm4Dw--.32829S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr47Zr4rtFyrAF4DCw4xtFb_yoW5WrW5pF Z3t34SyrWxJF4Yya18Cw1kA3Z8Ww4fGa4fWrWYkayrCan8JF1YkFZYgry2qa4kJr4ktr13 Za15Wr4jkFn5ArJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07Uq-erUUUUU= X-CM-SenderInfo: jorrjmiyzxliqr6rljoofrz/xtbC+Q+N0Wrq8+9h1wAA3A