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 20EDE1E86C; Mon, 1 Apr 2024 16:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711989558; cv=none; b=Z0f8HUCueSXTaStoWHP81QIRRlc43/wFPMhvwKptIkQgsRSYhJzttbV53OZ538KfI8ycRuAcS0t0FIIIAO0wGvEHraedMzgfWh8aLpcxdhx66J7jIw/Ph1HLdxLjq8YIAfA/OZiA/e1aVuu+voYQwzM+0sMcfGt7KBETuDBJ75w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711989558; c=relaxed/simple; bh=heTXu2o9gZIjWww33o8cyqrJqmDhcoK94aD1N+obpG4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SxqX9Mazny1BVui2sCEzCHTtiByELmicCp57yzKKJHguDJp2beLEySHA/zsU4OmUHRS2y5qv59A4Xd9/JiVumrVr5uuD4nGsBU1cYO9QlaGCYHGv9oS1zaoeDJ14YMB2WDWGePrF2n8nSRB5bdMVM4ZrKeWTjfSCAiL6jBXe4tk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=b8GE5aq2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="b8GE5aq2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83EF0C433C7; Mon, 1 Apr 2024 16:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711989558; bh=heTXu2o9gZIjWww33o8cyqrJqmDhcoK94aD1N+obpG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8GE5aq2Lz7GXS86rJe4dV5HH2jHtANRZjf9K+ankULNlADs/jikHIenCF2HDpwmR 7+yyCC5hfPkO50Rg2BpV828PewQckDaHWwUniXHGHYU29OK3ImLd+OTBZnLFw7R+n8 38swc68/hn/Pk53dV59DqvlgV3jdod1PyYrQ4Rq8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Palmer Dabbelt , Guenter Roeck , Charlie Jenkins , Helge Deller , Sasha Levin Subject: [PATCH 6.6 057/396] parisc: Fix csum_ipv6_magic on 64-bit systems Date: Mon, 1 Apr 2024 17:41:46 +0200 Message-ID: <20240401152549.625449062@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152547.867452742@linuxfoundation.org> References: <20240401152547.867452742@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guenter Roeck [ Upstream commit 4b75b12d70506e31fc02356bbca60f8d5ca012d0 ] hppa 64-bit systems calculates the IPv6 checksum using 64-bit add operations. The last add folds protocol and length fields into the 64-bit result. While unlikely, this operation can overflow. The overflow can be triggered with a code sequence such as the following. /* try to trigger massive overflows */ memset(tmp_buf, 0xff, sizeof(struct in6_addr)); csum_result = csum_ipv6_magic((struct in6_addr *)tmp_buf, (struct in6_addr *)tmp_buf, 0xffff, 0xff, 0xffffffff); Fix the problem by adding any overflows from the final add operation into the calculated checksum. Fortunately, we can do this without additional cost by replacing the add operation used to fold the checksum into 32 bit with "add,dc" to add in the missing carry. Cc: Palmer Dabbelt Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Guenter Roeck Reviewed-by: Charlie Jenkins Tested-by: Guenter Roeck Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- arch/parisc/include/asm/checksum.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/parisc/include/asm/checksum.h b/arch/parisc/include/asm/checksum.h index e619e67440db9..c949aa20fa162 100644 --- a/arch/parisc/include/asm/checksum.h +++ b/arch/parisc/include/asm/checksum.h @@ -137,8 +137,8 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, " add,dc %3, %0, %0\n" /* fold in proto+len | carry bit */ " extrd,u %0, 31, 32, %4\n"/* copy upper half down */ " depdi 0, 31, 32, %0\n"/* clear upper half */ -" add %4, %0, %0\n" /* fold into 32-bits */ -" addc 0, %0, %0\n" /* add carry */ +" add,dc %4, %0, %0\n" /* fold into 32-bits, plus carry */ +" addc 0, %0, %0\n" /* add final carry */ #else -- 2.43.0