Article View: linux.kernel.netdev
Article #12020[PATCH net v2 1/2] netfilter: conntrack: avoid secs-to-jiffies overflow in SIP helper
From: luoqing
Date: Fri, 06 Nov 2026 06:09
Date: Fri, 06 Nov 2026 06:09
82 lines
11916 bytes
11916 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". A wrapped product can only cut the lifetime short, never
extend it: at HZ=1000 an expiry of 2147484 seconds (24.9 days)
crosses 2^31, so the expectation is born expired and registration
refreshes break, while 4294968 seconds wraps to 704 jiffies and the
expectation is reaped almost immediately.
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. Oversized expiries now saturate to the
INT_MAX jiffies ceiling - about 24.8 days at HZ=1000 and 248 days at
HZ=100 - which is the same maximum a registrar could already request
with the largest non-wrapping value; the longest lifetime does not
change.
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>
---
v2:
- Clarified in the commit message that this patch introduces the
nf_ct_secs_to_jiffies() helper, which the subsequent H.323 patch depends on.
- Added a note about the stable backporting dependency for the helper.
- Addressed the Sashiko AI review comments.
v1: https://lore.kernel.org/all/20261104085925.773471-1-l1138897701@163.com/
---
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:
<20261106060948.540233-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-357771-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-357771-linux-kernel-netdev=dewy.ru From: l1138897701@163.com (luoqing) Newsgroups: linux.kernel.netdev Subject: [PATCH net v2 1/2] netfilter: conntrack: avoid secs-to-jiffies overflow in SIP helper Date: Fri, 6 Nov 2026 14:09:47 +0800 Organization: Usenet Network Message-ID: <20261106060948.540233-1-l1138897701@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3807221"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:x5TpAttzBrD2AKNv4lp9HoC4NhE= sha256:GCzfZ0qh+5XEpUXN+uMCi4GwKsxE49xvWQwKQjI6f4w= sha1:6AbMQq+c0TKz1/l6Hd+on2VUCS8= sha256:EMjsFsDN+1oNxvBP4A5p7uIIlZ9XKfV+k9zs7A/wEUw= 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 66950113171; Fri, 6 Nov 2026 09:12:59 +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 qI0icZrAfBIg; Fri, 6 Nov 2026 09:12:56 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-357771-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id C500811315D; Fri, 6 Nov 2026 09:12:47 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 09B4827AD3; Fri, 6 Nov 2026 06:11:26 +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=1793945485; b=UdgeBC16ZdP+ZCOMAcbXCAyfQyCKdsgUptg+4KRxi2srzIqaIEoYXAqsYSSxv252F41V DFQQqRLP3aWvrN56Z24yY0J9SiWawIVcDrz/B1ydlI6EtcDiz0A+gYTTVSDmk/pw0InKB KqyxCsggQiKEAVXx1r0GAISKWl8dw7bhyhDIMAO/XYF/iKUfWH0ra9KlQxfhUd8Tc9P9M IRd6m7bcqCXuB7W0AY1Wu76eNhHUuXGkKF3OInji8yDztNUuyln/QBmw/VYc5KScRNhLf O8F/+MMRWSmJ3NaziGV/G5kwg8R1WPNWhXswmSrOwrL7Rghjxct1azRHNjVl+/dGpQg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793945485; 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=8YF17ywi0dWJGRvCkQz9HkVWfG/t9IghxQFLb2psZSk=; b=ys9zeAfV+0ZIVI/JoexBX9GCq1ZKhs1PEsKIlLOip5F9U8QOyyMA+NGfchxP+XFsYlS6 XD3BgLcLo1eRs8ARJ6R6UEOU6ti6TecsedFLQd5TsQmsGW3E2hJuW0mk5Q26zJaKpiKmr Z0RZThKPyQ1QqHIwVHM2Y7Qy7ft3gvErfwqngc/AKz88r+XX66nKFbvgb76eGY4VBmORk m9uyVwECu0JUdI5H+aZUunzWvjiWp4wMZvIvTf2A+YOq9TS6aPxEuJWClaH1f56nnpXFD aFUlcsDNLwB9F9ZLd+weAT+VlnozyR9+a6JJVRiIrbH5wbPvWNnLgpgxlZSwDkenBDg== 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=YgMup7zM; 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 09FFC606A326; Fri, 6 Nov 2026 06:11:25 +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=YgMup7zM X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793945474; b=ks73vkrNberWNhLQ0xBTF52zSyVkEb7RRsbWxWNeiBLE8HZkW+ss7+3qWXcM6K1MN7sB iRkSJd72qikcODHtf+gSx9JhuEvVagq1IrP/Z8d1jPQ9+nmqGUAuk8dGjP8mXURqcrgsu 5D8LWczWCpjDjl+2tHh+Z+sf+p3LavQ3FOYhDAPjkpzULZMXDuIUpzLw2Hkx6fncaOBvQ Loep8iPL+5HG43v+A4wgF+LrlizwToex5t5vsAd9MZ5aO5ZudrHBLy1MyXYTmz7ondoX3 c4p70A45qlM3MbiAxbgk7IHi+4hEP5Fc9QUNKq8kRO3i8/YGooWlBHgGNDE1PkZ8H0g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793945474; 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=8YF17ywi0dWJGRvCkQz9HkVWfG/t9IghxQFLb2psZSk=; b=xAFCtv42C5nZ5qVJOiemF1vLpLTBjNLe3LPtJgyTcQTN+79v8Vb23b8S9rwDzLxyaKd1 MNLPWO1BuDX1yzCrpTJ9pYmkScIzhFj+T4mt9uwia6PWWt2uM/nyQJNXDmyr/BRGGV+LD r8JP1Smy4867ZxRhJq0cu6E7I3E/mzWb/l1ReVCkZCynAlP7/WeNt33Gg1I8/IiUs45cI eWHZy3SsDEzGima4VBOZjIALGwrCvBUkUVjjcAycy2Zg9zlhc2kVmN1e1irdaUwVSksQC pdXeZm+K10fAs/6T4uI8LwuEGaw6OKKHdlEIMpBAWU9eyr6xPEFrCEX+VbPN4zQr2IA== 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=YgMup7zM; arc=none smtp.remote-ip=117.135.210.4 X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4]) (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 81847606A328; Fri, 6 Nov 2026 06:11:10 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81847606A328 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=8Y F17ywi0dWJGRvCkQz9HkVWfG/t9IghxQFLb2psZSk=; b=YgMup7zM/fedPmb4Q8 ElAARwa4KSD9cPFRztZHcTWbK4j27JwOQ8lcd9KzYWU4HV8QKRJCXGgzBSHneIMV nuCjwbTbErUdXZhKM5dPqzldr4t6um8IUgBdgbG4yVWX3oCSwDQTU2lezvRWHc4x aJmJbRC9+jEq2TV6gVLthxnBg= X-Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-0 (Coremail) with SMTP id _____wD3fxMtb+1qBVQ1FA--.50369S2; Fri, 06 Nov 2026 14:09:51 +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: _____wD3fxMtb+1qBVQ1FA--.50369S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCr47Zr4fAryUAF45ZF48Crg_yoW5tw4DpF Z5t34Syr47XF4Fya1kCwn7A3Z8Ww4fGa4fWFWYk3yrCan8JF1rtFZ5Kry2qa4DJr4ktry3 Xay5Wr1jkF1kAFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U6q2_UUUUU= X-CM-SenderInfo: jorrjmiyzxliqr6rljoofrz/xtbC3Q-8QWrtby-JUwAA3y