From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CF1EE2E649 for ; Mon, 9 Oct 2023 13:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ju5CEkDt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD91FC433C7; Mon, 9 Oct 2023 13:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696858915; bh=665OEBUA/BcYOyHKOt70jFidWhLO4oA80Vhp4ZWwKXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ju5CEkDtXjIRFeBC0H0O0RV+CFdwhxz9hb/mdnkt1mpX8mSl8M+9E2C9jPB04AM9E eoZEaHOajQ+PWuF9BkXmmQGAyQ+5WSKsbiqYNBEjF/G8uNRW44FUljIhHQboMDWxc1 CswUxb1StCbJ2n/c7QXc43ccrfrfUaH7l3z4RDRM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Florian Westphal , Phil Sutter , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 140/226] netfilter: nft_exthdr: Fix for unsafe packet data read Date: Mon, 9 Oct 2023 15:01:41 +0200 Message-ID: <20231009130130.396884966@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231009130126.697995596@linuxfoundation.org> References: <20231009130126.697995596@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Phil Sutter [ Upstream commit cf6b5ffdce5a78b2fcb0e53b3a2487c490bcbf7f ] While iterating through an SCTP packet's chunks, skb_header_pointer() is called for the minimum expected chunk header size. If (that part of) the skbuff is non-linear, the following memcpy() may read data past temporary buffer '_sch'. Use skb_copy_bits() instead which does the right thing in this situation. Fixes: 133dc203d77df ("netfilter: nft_exthdr: Support SCTP chunks") Suggested-by: Florian Westphal Signed-off-by: Phil Sutter Reviewed-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_exthdr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c index 274c5f0085186..eb183c024ac46 100644 --- a/net/netfilter/nft_exthdr.c +++ b/net/netfilter/nft_exthdr.c @@ -389,7 +389,9 @@ static void nft_exthdr_sctp_eval(const struct nft_expr *expr, break; dest[priv->len / NFT_REG32_SIZE] = 0; - memcpy(dest, (char *)sch + priv->offset, priv->len); + if (skb_copy_bits(pkt->skb, offset + priv->offset, + dest, priv->len) < 0) + break; return; } offset += SCTP_PAD4(ntohs(sch->length)); -- 2.40.1