From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5BBC3AE6EF; Fri, 13 Mar 2026 15:07:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.245.30 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773414433; cv=none; b=VZeAA8oxVjRP7xdn8H2dPnXz0rz7sWsVr2A//WPBj1mTZypypC4/gdZwijBHDNjRYNqZ88jQgn+H6V9620yD0BtCH96ZjbV7xiN6Z/qmWEfdPIUq9DDKCljetW9IBK3zImvpOMLDpHpVwW3JjBj4I/s27X6pcwAfv0+JIzP8emQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773414433; c=relaxed/simple; bh=2c1n4uTROS8aPSVsC7CX161ivvqsaaeicRbPfKvU3jY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pEdz7BDTgtZjap5b/PCmQHkzplXruZDl/g4XW7K/6HGuiKOVGNuJPkB8Dy/nsHABoXy0hZnEJV3NM+kW199sMrgEp290PqAo2HQ2g+/waOzG8mftMXGsMySFjIjkIlZ6+iVUFuRvMBCo/4Ib7YyygXvvLuyDOTZtKqvaVekxBYM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de; spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc; arc=none smtp.client-ip=91.216.245.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc Received: by Chamillionaire.breakpoint.cc (Postfix, from userid 1003) id 58BA160910; Fri, 13 Mar 2026 16:07:09 +0100 (CET) From: Florian Westphal To: Cc: Paolo Abeni , "David S. Miller" , Eric Dumazet , Jakub Kicinski , , pablo@netfilter.org Subject: [PATCH net 11/11] netfilter: nf_conntrack_h323: check for zero length in DecodeQ931() Date: Fri, 13 Mar 2026 16:06:14 +0100 Message-ID: <20260313150614.21177-12-fw@strlen.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260313150614.21177-1-fw@strlen.de> References: <20260313150614.21177-1-fw@strlen.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jenny Guanni Qu 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 Reported-by: Dawid Moczadło Tested-by: Jenny Guanni Qu Signed-off-by: Jenny Guanni Qu Signed-off-by: Florian Westphal --- 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 c972e9488e16..7b1497ed97d2 100644 --- a/net/netfilter/nf_conntrack_h323_asn1.c +++ b/net/netfilter/nf_conntrack_h323_asn1.c @@ -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); } -- 2.52.0