]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: nf_conntrack_h323: check for zero length in DecodeQ931()
authorJenny Guanni Qu <qguanni@gmail.com>
Thu, 12 Mar 2026 14:49:50 +0000 (14:49 +0000)
committerFlorian Westphal <fw@strlen.de>
Fri, 13 Mar 2026 14:31:15 +0000 (15:31 +0100)
In DecodeQ931(), the UserUserIE code path reads a 16-bit length from
the packet, then decrements it by 1 to skip the protocol discriminator
byte before passing it to DecodeH323_UserInformation(). If the encoded
length is 0, the decrement wraps to -1, which is then passed as a
large value to the decoder, leading to an out-of-bounds read.

Add a check to ensure len is positive after the decrement.

Fixes: 5e35941d9901 ("[NETFILTER]: Add H.323 conntrack/NAT helper")
Reported-by: Klaudia Kloc <klaudia@vidocsecurity.com>
Reported-by: Dawid Moczadło <dawid@vidocsecurity.com>
Tested-by: Jenny Guanni Qu <qguanni@gmail.com>
Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nf_conntrack_h323_asn1.c

index c972e9488e16f63c7084b92285f72bbaff124ce9..7b1497ed97d26958bc88b91335e927b913212a35 100644 (file)
@@ -924,6 +924,8 @@ int DecodeQ931(unsigned char *buf, size_t sz, Q931 *q931)
                                break;
                        p++;
                        len--;
+                       if (len <= 0)
+                               break;
                        return DecodeH323_UserInformation(buf, p, len,
                                                          &q931->UUIE);
                }