* [PATCH] netfilter: nf_conntrack_h323: fix NULL deref in decode_seqof()
@ 2026-10-12 9:08 Guanglei Zhu
2026-10-12 9:12 ` Florian Westphal
2026-10-12 9:20 ` Guanglei Zhu
0 siblings, 2 replies; 3+ messages in thread
From: Guanglei Zhu @ 2026-10-12 9:08 UTC (permalink / raw)
To: Pablo Neira Ayuso, Florian Westphal
Cc: Phil Sutter, netfilter-devel, linux-kernel, liuwb
decode_seqof() loads son from f->fields and dereferences son->attr
in the item loop without a NULL check. A number of SEQOF entries
in nf_conntrack_h323_types.c carry a NULL fields pointer, so a
crafted packet that makes one of these optional fields present with
a nonzero item count dereferences NULL in the loop.
Skip the decoding when fields is NULL.
Signed-off-by: Guanglei Zhu <zhugl3@xiaopeng.com>
---
Verified on a KASAN kernel with a test module calling decode_seqof()
with a fields=NULL SEQOF entry and a nonzero item count: NULL deref
report at son->attr (read of size 2 at address 0x4).
net/netfilter/nf_conntrack_h323_asn1.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/netfilter/nf_conntrack_h323_asn1.c b/net/netfilter/nf_conntrack_h323_asn1.c
index 6830c9da3..0d07d0276 100644
--- a/net/netfilter/nf_conntrack_h323_asn1.c
+++ b/net/netfilter/nf_conntrack_h323_asn1.c
@@ -691,6 +691,8 @@ static int decode_seqof(struct bitstr *bs, const struct field_t *f,
}
/* Decode nested field */
+ if (!f->fields)
+ return H323_ERROR_NONE;
son = f->fields;
if (base)
base -= son->offset;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] netfilter: nf_conntrack_h323: fix NULL deref in decode_seqof()
2026-10-12 9:08 [PATCH] netfilter: nf_conntrack_h323: fix NULL deref in decode_seqof() Guanglei Zhu
@ 2026-10-12 9:12 ` Florian Westphal
2026-10-12 9:20 ` Guanglei Zhu
1 sibling, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2026-10-12 9:12 UTC (permalink / raw)
To: Guanglei Zhu
Cc: Pablo Neira Ayuso, Phil Sutter, netfilter-devel, linux-kernel,
liuwb
Guanglei Zhu <zhugl3@xiaopeng.com> wrote:
> decode_seqof() loads son from f->fields and dereferences son->attr
> in the item loop without a NULL check. A number of SEQOF entries
> in nf_conntrack_h323_types.c carry a NULL fields pointer, so a
> crafted packet that makes one of these optional fields present with
> a nonzero item count dereferences NULL in the loop.
>
> Skip the decoding when fields is NULL.
>
> Signed-off-by: Guanglei Zhu <zhugl3@xiaopeng.com>
> ---
> Verified on a KASAN kernel with a test module calling decode_seqof()
> with a fields=NULL SEQOF entry and a nonzero item count: NULL deref
> report at son->attr (read of size 2 at address 0x4).
We don't add NULL tests unless there is a sensibe reason.
Will you add NULL tests to other functions too because a 3rd party
module would crash otherwise?
If this is reachable, show how.
> diff --git a/net/netfilter/nf_conntrack_h323_asn1.c b/net/netfilter/nf_conntrack_h323_asn1.c
> index 6830c9da3..0d07d0276 100644
> --- a/net/netfilter/nf_conntrack_h323_asn1.c
> +++ b/net/netfilter/nf_conntrack_h323_asn1.c
> @@ -691,6 +691,8 @@ static int decode_seqof(struct bitstr *bs, const struct field_t *f,
> }
>
> /* Decode nested field */
> + if (!f->fields)
> + return H323_ERROR_NONE;
> son = f->fields;
This is strange.
son = f->fields;
if (!son)...
would be more natural.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] netfilter: nf_conntrack_h323: fix NULL deref in decode_seqof()
2026-10-12 9:08 [PATCH] netfilter: nf_conntrack_h323: fix NULL deref in decode_seqof() Guanglei Zhu
2026-10-12 9:12 ` Florian Westphal
@ 2026-10-12 9:20 ` Guanglei Zhu
1 sibling, 0 replies; 3+ messages in thread
From: Guanglei Zhu @ 2026-10-12 9:20 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel, linux-kernel, pablo, phil, liuwb
You are right, I could not find a reachable path either.
I re-checked all call sites that would invoke decode_seqof() without
a DECODE guard:
- decode_seq() root loop: every SEQOF entry with a NULL fields
pointer sits outside the root window (index >= f->lb); the ones
inside the root window carry STOP or OPEN.
- decode_seq() extension loop: entries without DECODE are skipped
with bs->cur += len, decode_seqof() is never called for them.
- decode_choice() and the decode_seqof() item loop: no NULL-fields
SEQOF entries among the options/items without STOP or OPEN either.
So f->fields can only be NULL when decode_seqof() is called from
outside the decoder, which is what my test module did. The KASAN
report only demonstrates the in-function deref, not reachability
from a packet.
Please drop this patch.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-12 9:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 9:08 [PATCH] netfilter: nf_conntrack_h323: fix NULL deref in decode_seqof() Guanglei Zhu
2026-10-12 9:12 ` Florian Westphal
2026-10-12 9:20 ` Guanglei Zhu
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.