Article View: linux.kernel.netdev
Article #23380[PATCH nf] netfilter: nf_nat_h323: fix UDP mangle offset in set_addr()
From: Henry Martin
Date: Fri, 27 Nov 2026 06:55
Date: Fri, 27 Nov 2026 06:55
61 lines
12910 bytes
12910 bytes
set_addr() unconditionally adds dataoff to the embedded-address offset
before mangling the packet. That is correct for TCP, where
nf_nat_mangle_tcp_packet() counts match_offset from the TCP header and
dataoff carries the TPKT header length. For UDP,
nf_nat_mangle_udp_packet() already counts from the UDP payload, which
is where the decoded H.245 data starts, so the extra dataoff shifts the
write past the address. When the decoded address sits at the end of
the payload, the shifted match_end runs past the skb tail and the
memmove() length in mangle_contents() underflows, turning into a huge
copy that runs off the mapped pages:
e.g. on mainline v7.4-rc4 (KASAN build):
BUG: unable to handle page fault for address: ffff888140000000
CPU: 1 UID: 1000 PID: 82 Comm: poc Tainted: G O 7.4.0-rc4 #2
RIP: 0010:memmove+0x91/0x1c0
RDX: fffffffffffffffe RSI: ffff88813ffffffe RDI: ffff88813ffffffe
Call Trace:
nf_nat_mangle_udp_packet+0x13f/0x420
set_addr+0x18a/0x830
nat_rtp_rtcp+0x50e/0x910
h245_help+0x1eb/0x240
nf_confirm+0x481/0x8c0
raw_sendmsg+0x203d/0x2630
Only add dataoff on the TCP path.
This issue was discovered by Tencent CodeBuddy Security.
Cc: stable@vger.kernel.org
Fixes: f587de0e2feb ("[NETFILTER]: nf_conntrack/nf_nat: add H.323 helper port")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
net/ipv4/netfilter/nf_nat_h323.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c
index 6bcd6734769b5..764bfc89027f6 100644
--- a/net/ipv4/netfilter/nf_nat_h323.c
+++ b/net/ipv4/netfilter/nf_nat_h323.c
@@ -35,9 +35,16 @@ static int set_addr(struct sk_buff *skb, unsigned int protoff,
buf.ip = ip;
buf.port = port;
- addroff += dataoff;
if (ip_hdr(skb)->protocol == IPPROTO_TCP) {
+ /* nf_nat_mangle_tcp_packet() counts match_offset from the
+ * TCP header, so move the offset past the TPKT header.
+ * nf_nat_mangle_udp_packet() already counts from the UDP
+ * payload, where the decoded data starts; adding dataoff
+ * there writes past the address and can underflow the
+ * memmove() length in mangle_contents().
+ */
+ addroff += dataoff;
if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo,
protoff, addroff, sizeof(buf),
(char *) &buf, sizeof(buf))) {
--
2.39.5
Technical Details
Message-ID:
<20261127065509.2925843-1-bsdhenrymartin@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372507-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372507-linux-kernel-netdev=dewy.ru
From: bsdhenrymartin@gmail.com (Henry Martin)
Newsgroups: linux.kernel.netdev
Subject: [PATCH nf] netfilter: nf_nat_h323: fix UDP mangle offset in set_addr()
Date: Fri, 27 Nov 2026 14:55:09 +0800
Organization: Usenet Network
Message-ID: <20261127065509.2925843-1-bsdhenrymartin@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="663150"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:h+PmXudFjFySGjQgl3OmLrO+HeU= sha256:/0Ifp49vJcY707wOUj/A2js0G30LsJXS/8+75l/SoiI=
sha1:9wjWpZXpJ7hhItNP+pUuf+L4Tq8= sha256:PzLAZ4M67Dd8UcINHDcFQDl5RBkq2O0dpRfnJVQolq4=
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 E2592125F13; Fri, 27 Nov 2026 09:55:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[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]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.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 UXrRcIVVEmoM;
Fri, 27 Nov 2026 09:55:30 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-372507-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 2B174125F10; Fri, 27 Nov 2026 09:55:22 +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 E858C27519; Fri, 27 Nov 2026 06:55:20 +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=1795762520;
b=L5FVfX157Ux4Nzn/qavnbrgAXzScw+F2ssHQIInHlpz0EVCdTvCtx6Nf9crTf9PWXv6C
VEFT/3ytVeG6ksMkF9sdXXxub9quX9Kn3r2CyEpumpmpQYQ3pS2lfUdc6TIRv3PCccsy0
g+kDVIkgydKCAnTOVrCRYtj1KxfHNeD1Riss2EHy6CUN8Ha8IcjofSu3sjlu6rPro8hxK
4esTW3yts7wc/UFCAD0DPzjAFejPIFEtqoNKTqQaGujfhM863t80iLRMpJi5UncWe1tls
PY7nBddYDECrsKTiGg345kI/cd/nT/QkKtKXPuNbR6l+ZHGNE8MDsdI7mDZJS9T0tuA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795762520;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received: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;
bh=erNRx/pa4ybfvht61Cy5QMsfcLY/xQhwXhQlf25RgsI=;
b=0cyLLQcqENxAIbc9ouLB07OlRfF71BfQRbQgkA8CTfNCicfbiXHMB8fQ/1jFETUcP5LZ
1xdWu6nHbfps2gjKxtT+teT+WGARt3W6jIzvAv9EM99ZXW5rQhVycQ/wcwXXEdhsWfkFx
vbT97OmWIh40sVEkUM1sjKTpKQCeJpQItEDBO2sbvaT6tlUQU1hHk3dvFCYjFoukDkPWK
74wQMISK2bRh3et5Z05geUaYRVXFsea5vaT1eh3idiNxjzEjg/d1fXsJb0lPaMMtws7NX
rfGRSqv2w9OjBIahWVCTXA65xIWNOGcP1SQcIDLxz0SQSH+qyaqJTg5eKTdL5LVwdrQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Xw6a4Wdb;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.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 90CFD606A32D;
Fri, 27 Nov 2026 06:55:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Xw6a4Wdb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.227.134
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795762519;
b=032Tf5B5/pPYPN0o8bPHZwjPIAxjEn38yMads5gImhsHb7mPnl7tSrz93BnXNc8mhyNB
6bYtPJfEMHFh1JV/8Dp18+lYggCSBrJyt9pHG0MEDr0EgbxmDJQB4KrZgqQnvqYGK/4QQ
KCRt8i97G5yj0UsO5OdywE8wcaaw60vQKYJlLrCf/VjpvQaTSQTpDy+usyNQS1n7anH0b
vbuUfRvSqzoRm4KkGgeUCrHDSmSrUVfIFQtIErv1ZII39T/I8C0fM/E+QYyiA/72lCtIR
CF66MdPiDIJTThWi0c1N+zwa6BXfEZGZdJLIOuKJH+sozNV7ovYz4xyZKgFh/War6eQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795762519;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=erNRx/pa4ybfvht61Cy5QMsfcLY/xQhwXhQlf25RgsI=;
b=ZTEPcBCEZOt2m5yCxOHjp9W+MFmazQA4H4roJPjbpsukArqA9n6kYqgHcR1I6J7zhub5
NYlqjPmpoCHBl1d7egYrM0yydpKEJOxANiyW6ZEhKcWvDrR/hxip+WaW2dGiaLf1uq1iO
5g1g7qbhBuIZeoeKdKlQ6BB+aA+x8K2rA6T85IiL6mLX1Hgu6KJ/D9M+HRxe+2RUtXHKg
hN4HkpD383pFf3+7uuWBHahbt5LxJ4aorTiBl9mqX7dW3AAUxVilzY+ZE5kkO47gKZ2OQ
SvSwdkMaN7PIveKZ/AdqStueYKgsPCqAVSsxQ5NAGqN5I4lmJjMOyzEONnJ1/1mSJMw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Xw6a4Wdb;
arc=none smtp.remote-ip=74.125.227.134
X-Received: from mail-pj2-f6.google.com (mail-pj2-f6.google.com [74.125.227.134])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65EC7606A321
for <netdev@vger.kernel.org>; Fri, 27 Nov 2026 06:55:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 65EC7606A321
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj2-f6.google.com with SMTP id d9443c01a7336-2f08b80a840so41953445ad.1
for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 22:55:19 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795762519; x=1796367319; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=erNRx/pa4ybfvht61Cy5QMsfcLY/xQhwXhQlf25RgsI=;
b=Xw6a4WdbBuEohq4yjyZKoO3Y1qKNC6rBR2ZO+XR5X6FRoZhnMgDRDKVx1a+BQp4RHj
Yy9SJixfy91qcMTmAQVIZTKHvG5A72rknRFllvO5+Zdi3rHQmLcbQciJE9CzpU1AJ0hO
dyun41/ut8Njp4vByLSGE6fE+8sNxKbOnJgwcffLCkUqIdbc5ENGp2sFWI0L1KUjO+w3
QBbNqQuHP1GTIL90KSnMaJ4PEkWcbWusKPqxvuCxI0taO/uWECcDfIq20lJ5guSi/muP
iwwaJiQDPH5AolyhtfATtNPfkFASCQ2ROi9XRq1vgAlKkJLL8tkCMmAIM7JG2nFuvVUT
fjFA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795762519; x=1796367319;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=erNRx/pa4ybfvht61Cy5QMsfcLY/xQhwXhQlf25RgsI=;
b=2pWNRkEgUKndw6I3N0NFioaqDzdKzaDSvQcmhuiYtFvM/CMNvpUZouEF/BiVvhQEPJ
Pjw1tDc+WCq3LcZQ5x6qrF9Ys6/HjIT9hrRdyxQvNxJGX94LZ8Gvr25kysVtppD4xbbp
g4rpBn+lp2A9y1PQgiMiXSkSrfvGcGonDgHb9ddP9E93RMCoCnQ0ejhEtgMCqH1imKUx
mXDSsVFpWDEmZ0RBZE/Lir3FQpR8Z1/bpTZ4bxwhSJ5BSDRPEubJr6rGBhcvPYa/V7O4
sHeFg52CSMVL+RYBNwA1A0glUZ70wznNRhyjsjoBr9cp5xajsxxlJvK05uQwK90b2Jhq
Lssw==
X-Forwarded-Encrypted: i=1; AL+hErGRqn5euqVmdzq4zqkY4ZJsi6SrySbrMhZJF/KDzEWraybeA2aqWs5bki+4UhGiUs7z+C+3REs=@vger.kernel.org
X-Gm-Message-State: APuU4Z9X9F3c5wt2FHTpLv2NRzdyu8koE6UZq/nrxUQVHts+mPLG1Gif
+0uTNTPvafjkSn2GOafvHumoYf1fUKxzTsYDuKMsnUMBkM11g/D6zHdj
X-Gm-Gg: AZFdTZfLOiLmdttsM9x0c/9R2b6WtXUqlW6/SA87exCpiawrBV7laR5oKM8ek60LOcF
iYhQ9yv+PhrK8kgEJAMCWrnE3d28cqROX0DzA5a5ZRDTl40jcGHWL2oicEWpbX9Eq3en2GCP563
MRcFvUkcI8TueuJDpUY6+Ss1JrtoophVqOXyPHMvHe+egKJDpRIk6iGjl+4uKzyjgxUxI+NBZqP
aMFzsqK6CN3hJJyMqRSED5JIymVmrnQCCsbTPYaSW7KrmsMughSctMoqK0sSxuTmfNXU1rqmlXW
WJrEJyVQXy/zly+33rGR+xFkZGY3nafN2YKVEKE7SBpK7cKDIUA6r0+yn9GOhUoHzK93CY27a0N
M9GMLAhST7E7SxM9q41ueyIDajamvWciPOIzPhxrRdFVmm0i2j19ObAcPp0pPVIh1m7jysoHpWh
nX1ZyuliWeQNSn1ezWM/ith8P1/hcF6fYB//HhH7Z90zb15Z1iH15KJzywkp5xVVELFgYGYDbVl
Ti3ZRtiWUltIgX4JmTjnsRUogBNLxFnaPa/XuZTCrUL9geZTSWxU5AjGJqpoSZrd0csmdgbEJnr
hnkDkVogESrCPbMFr72UV7c9azz9XTKZePj+SVyrD4Seuf0HsABlX+Tejwm4kk4tfDYN5kl+uFA
I
X-Received: by 2002:a05:6a21:32a6:b0:3fb:3a56:e41b with SMTP id adf61e73a8af0-4014db62821mr29894274637.48.1795762518648;
Thu, 26 Nov 2026 22:55:18 -0800 (PST)
X-Received: from BSDHENRYMA-PC1.localdomain ([43.132.141.19])
by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87353b333sm11793302b3a.40.2026.11.26.22.55.13
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 26 Nov 2026 22:55:18 -0800 (PST)
X-Cc: netfilter-devel@vger.kernel.org,
coreteam@netfilter.org,
netdev@vger.kernel.org,
Henry Martin <bsdhenrymartin@gmail.com>,
stable@vger.kernel.org
X-Mailer: git-send-email 2.53.0
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