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=1796384506; b=e4ddbJNYFBf4ZrW4yTKzislR2CjomTj7FqIwG1Eku47rkzxNW6O4ZVvjejbShmGxRt7U wgAiRet0yC6MuiYOjlVsnTwBZN0bNRhj2RZUpV5NE5jNah3ICNXFjfkelV7FVzVsvUCq8 JeUr79dwBjTvLGdcG1ytar9e7zrJI0xvlTJ/Ng3BbR7O94Vt4XjdmYqIsKHos2Fnifjp/ t7KuAdY/ywgfRYCFiD8vSJ3u+O4BhsyewpM+S8jBc+ZxPh7Sd2btYdpafj0BEfrpeaUvz bEeEVCpBcJ9AadDrGMymD/IQHLr54NrWey+VRR9przYC9lI4Hm0Dg4uClkcpUxY29vg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384506; 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=RsMH8OFa554tryO3t9OWDYbwlpCwS4tN1erLTQQ4ly0=; b=bowO0rE0tIZRGosRiBrEKj6HvyTrMkY0hwBKqP2hfHkEP5HHj5kM+UWvD8hMHumVgMht s3ObZWSCIWy8nV/ghIaQMtTwYkC4eU6aUJZ9RJwvZgq4mMDdv02qn/zxkDSLgWhgGdImN 0S/2WqbhgnXRCeXwBg/RRvF2cy/7fLFvmNRcpP0wkYc83JRu1CEJfYq1ZLnU4DQAY92aQ i7WPfcOeoKHrJMJGHqFUkSJDQJfAU5VsajOpkd8UQbxbMCyCyAmHdFqrWRoB3N1N66KAx awW9CuLSYO1y1veWs0Ud2XQNfPbUrs4S0CvW83UM7wJB0o8dOXZW36Wy6zPW2GQ11Cg== 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="aVUn/cGF"; 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 7741F606A32C; Fri, 4 Dec 2026 11:41:46 +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=aVUn/cGF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B8C91F000C2; Fri, 4 Dec 2026 11:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384506; bh=RsMH8OFa554tryO3t9OWDYbwlpCwS4tN1erLTQQ4ly0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aVUn/cGFalvkF+PKV1XEFnDSAdQMZv8InS2mTa6pJEV76aDILjJxK17kh9jwCjQwi 3hrDQ7wzKVKlFDDZarwBX8LjqsRXPnhw3ImRXdbrwvNiy8rw5AcaVC3f/urJodo+gv LVFuR6DbJ8/7p4TvkZwYXPBfMY51X4DUR7erSQgk= 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.6 0178/1167] netfilter: nf_conntrack_sip: fix OOB read in ct_sip_parse_transport() Date: Fri, 4 Dec 2026 18:53:25 +0900 Message-ID: <20261204100706.705488203@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 449a6e53feae4..12b8c7fcca640 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