From: Jenny Guanni Qu <qguanni@gmail.com>
To: pablo@netfilter.org, kadlec@netfilter.org
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de,
Jenny Guanni Qu <qguanni@gmail.com>
Subject: [PATCH] netfilter: nf_nat_sip: validate exp->dir in nf_nat_sip_expected()
Date: Fri, 13 Mar 2026 20:13:46 +0000 [thread overview]
Message-ID: <20260313201346.562476-1-qguanni@gmail.com> (raw)
nf_nat_sip_expected() uses exp->dir to index into the 2-element
tuplehash[] array without bounds checking. If exp->dir has an
out-of-range value, this causes a slab-out-of-bounds read.
KASAN reports:
BUG: KASAN: slab-out-of-bounds in nf_nat_sip_expected+0x804/0x938
Read of size 8 at addr ffff0000d113e3b8
The buggy address is located 72 bytes to the right of
allocated 240-byte region
Add a bounds check to ensure exp->dir is less than IP_CT_DIR_MAX.
Fixes: 9a6648210687 ("netfilter: nf_nat: support IPv6 in SIP NAT helper")
Reported-by: Jenny Guanni Qu <qguanni@gmail.com>
Tested-by: Jenny Guanni Qu <qguanni@gmail.com>
Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com>
---
net/netfilter/nf_nat_sip.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/netfilter/nf_nat_sip.c b/net/netfilter/nf_nat_sip.c
index cf4aeb299bde..48b1b2d70a1e 100644
--- a/net/netfilter/nf_nat_sip.c
+++ b/net/netfilter/nf_nat_sip.c
@@ -326,6 +326,9 @@ static void nf_nat_sip_expected(struct nf_conn *ct,
/* This must be a fresh one. */
BUG_ON(ct->status & IPS_NAT_DONE_MASK);
+ if (exp->dir >= IP_CT_DIR_MAX)
+ return;
+
/* For DST manip, map port here to where it's expected. */
range.flags = (NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED);
range.min_proto = range.max_proto = exp->saved_proto;
--
2.34.1
next reply other threads:[~2026-03-13 20:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 20:13 Jenny Guanni Qu [this message]
2026-03-13 23:32 ` [PATCH] netfilter: nf_nat_sip: validate exp->dir in nf_nat_sip_expected() Florian Westphal
2026-03-14 11:50 ` Pablo Neira Ayuso
2026-03-14 22:21 ` Guanni Qu
2026-03-15 7:26 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313201346.562476-1-qguanni@gmail.com \
--to=qguanni@gmail.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.