Skip to content
/ linux Public

Commit 6bce72d

Browse files
Jenny Guanni Qugregkh
authored andcommitted
netfilter: nf_conntrack_h323: fix OOB read in decode_int() CONS case
[ Upstream commit 1e3a359 ] In decode_int(), the CONS case calls get_bits(bs, 2) to read a length value, then calls get_uint(bs, len) without checking that len bytes remain in the buffer. The existing boundary check only validates the 2 bits for get_bits(), not the subsequent 1-4 bytes that get_uint() reads. This allows a malformed H.323/RAS packet to cause a 1-4 byte slab-out-of-bounds read. Add a boundary check for len bytes after get_bits() and before get_uint(). Fixes: 5e35941 ("[NETFILTER]: Add H.323 conntrack/NAT helper") Reported-by: Klaudia Kloc <klaudia@vidocsecurity.com> Reported-by: Dawid Moczadło <dawid@vidocsecurity.com> Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 865dba5 commit 6bce72d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/netfilter/nf_conntrack_h323_asn1.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ static int decode_int(struct bitstr *bs, const struct field_t *f,
331331
if (nf_h323_error_boundary(bs, 0, 2))
332332
return H323_ERROR_BOUND;
333333
len = get_bits(bs, 2) + 1;
334+
if (nf_h323_error_boundary(bs, len, 0))
335+
return H323_ERROR_BOUND;
334336
BYTE_ALIGN(bs);
335337
if (base && (f->attr & DECODE)) { /* timeToLive */
336338
unsigned int v = get_uint(bs, len) + f->lb;

0 commit comments

Comments
 (0)