From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387178; b=AQJRDL9yq6rDMFYm1c8/Qkh0ZcEMV5btZV+eN3pFa+wIpnXzxfIZKJc7iNCjSOV8G1z7 ANNcC6AD0yepUVzIYROkuhhiU55xkFxyDo7PyjWoMi67wXCr1hDFSE8UobAnj16UnmLQo pfaccwg8Ci+khwpt4n7g3vKBW1fEoOEhO5jRSvKBGqDAVpkFFeaIEHEVFIcSXYP42tf+U KoyLcyhlX6J0kyyjHyqYqd0mVWyyhvk/xVAp7MgB2VmgADOflGtoUBmGAqSVhaQZFQR9b 0WJhgMVV4m+y+KmM/ahsGLSUZ2bsUB3VtdS/8ouaFFevEUvZ1RQqY/sckV4n8x/0Asw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387178; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Q4YIxQjTOZX2f51GwBxCO3MGYPThovu27jAyKN0TjgU=; b=2psQWXygJEFOxt2Ub/PJ/j5iQ7Dy1vQrDuqpdUI4qWa3FfpD4uiKmC23XkPam7AzlT0P wCuDHR2yzrNN5zosRTaoHV3GuspfQf6Cb8b4wtYoGVusDunFH7xht3JJ2fNc7caiQ0llu Lu6y6mbHxTM3LTiz4tUHuF9py7X21/LrBLzhdNggLJfWsNjKJUmKsp7HwurzbvHGw0yki psLc18EhnYRfxwACcATdSwBB98RxerTbKJPIcNqFb3IZbXTxvAhpCGrH1gYa1VHGa6xsc WhHMlFDuCtlYEvyNfUpVNjpE9yPkebUxgTDcTzHBslTreepFBgKyr8fBJjv5LYL9HVQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fTRYTtI+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74B90606A32D; Fri, 4 Dec 2026 12:26:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=fTRYTtI+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id E00771F000C2; Fri, 4 Dec 2026 12:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387178; bh=Q4YIxQjTOZX2f51GwBxCO3MGYPThovu27jAyKN0TjgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fTRYTtI+YswdjRh/Wd71QINenmiUGk1ao0MUwYsh+cBf0F9xLW81MpPqv3m4GcUoa PLBnk0wdW815V5897NIwTFpVUF72S7Er5YBvAssAsL42Y1Zk3a5KBl1qrRTau7xzq0 wovr6cOzQVnETrMtN4CZUXhcfoTIymjPHaHy/6J8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Fernando Fernandez Mancera , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.1 0134/1059] netfilter: nf_conntrack_sip: fix OOB read in ct_sip_parse_transport() Date: Fri, 4 Dec 2026 18:54:25 +0900 Message-ID: <20261204100647.692085612@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos [ Upstream commit 7af52bda65c0bbbf40894aa3df36ac1bb5697984 ] ct_sip_parse_transport() compares the value of the "transport=" header parameter against "TCP"/"UDP" with strncasecmp(..., 3), but it never checks that the parsed value is at least 3 bytes long. ct_sip_parse_param() returns matchlen = end - start, where end is the next ';' or, when there is no ';', the end of the payload buffer (limit = dptr + datalen). If the "transport=" value is only 1 or 2 bytes long and runs exactly to the end of the payload (e.g. a REGISTER request whose Contact header ends in ";transport=T" with no trailing CRLF), matchlen is less than 3 while strncasecmp() still reads up to 3 bytes, reading 1-2 bytes past the end of the linearized skb data. Add a matchlen check before the comparison, mirroring the sdp_media_type() pattern a few lines below, so short values cannot reach strncasecmp(). The bug was found by LLM-assisted manual review of the SIP helper's parsers and confirmed with a userspace ASan harness built from the verbatim parser functions, which reports a heap-buffer-overflow read of size 2 in strncasecmp() called from ct_sip_parse_transport(). Fixes: ea45f12a2766d ("[NETFILTER]: nf_conntrack_sip: parse SIP headers properly") Link: https://patch.msgid.link/20260815133104.50369-1-joasantonio108@gmail.com/ Signed-off-by: Joas Antonio dos Santos Assisted-by: Claude:claude-opus-5-5 Reviewed-by: Fernando Fernandez Mancera Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_conntrack_sip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 3cab167224ec1..7b6c7023c7359 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c @@ -707,9 +707,9 @@ static int ct_sip_parse_transport(struct nf_conn *ct, const char *dptr, if (ct_sip_parse_param(ct, dptr, dataoff, datalen, "transport=", &matchoff, &matchlen)) { - if (!strncasecmp(dptr + matchoff, "TCP", strlen("TCP"))) + if (matchlen >= 3 && !strncasecmp(dptr + matchoff, "TCP", 3)) *proto = IPPROTO_TCP; - else if (!strncasecmp(dptr + matchoff, "UDP", strlen("UDP"))) + else if (matchlen >= 3 && !strncasecmp(dptr + matchoff, "UDP", 3)) *proto = IPPROTO_UDP; else return 0; -- 2.53.0