From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0CD8A37E5D1; Sat, 12 Sep 2026 13:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789220506; cv=none; b=LGipgUv6CYK0wPIutaDPxLw6wUm9hhl1yh/2qucPdYz5H8xkgykc1MUrFm7x//HKzVLJmVX6XAxOskDtJbjfPKMKJBGoKzaOTVg9AwnD/zmgV9cbJPl9A+sqwKLihGPTncboRuLeCJ+HAW0zNtrQP25PYuvJgsfIFfS09bAzKBM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789220506; c=relaxed/simple; bh=DTHT22HdlZI+h12szVB8PkMYjp2GtWQCZukSivIw/Qc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R0fMQ9z7rbIic6fKUdVnaGV/Ono3ia50by9jNsa7j4SfVmKdVrNs3rZ/8Fj2smrFXmb1URMtpWd6KxGfpXeFCp1ajPKZ0h2zFyV8HRTSdLjxWYlh1dbXJXySY2b9Z8KgJHy39GcO2HOUNfzENLf9BdTTKg6aMb0n5iaiw0rBd5o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=X76PEgrO; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="X76PEgrO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1B9F1F000FF; Sat, 12 Sep 2026 13:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789220504; bh=KjSgP0pZlMUM0QRpHVXYv8m3akfUpFkNs5EWxpTVttQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=X76PEgrOOPbX81xHrksaDfBPOwwCv9bJ86z46OPk30tiKd4+J+GoG7t8BMxitzeMq EuCBYis1lT5fqMsGqILOIVYzjUxG5GTLIhGzw/hRPYcvlv8KMw3dzUbiyN5NwToX2V 90LApofilN158kRKD2hmS0NuqzQQValN0+S4Z2HA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Arnd Bergmann , Karl Mehltretter , Will Deacon Subject: [PATCH 6.6 0190/1424] arm64: compat: Fix decrementing LDM/STM alignment emulation Date: Sat, 12 Sep 2026 08:43:42 +0200 Message-ID: <20260912065611.542338916@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@linuxfoundation.org> User-Agent: quilt/0.69 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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karl Mehltretter commit f5b8b9037df387394a73aab47c5437bbac975077 upstream. The compat alignment emulator inherited unsigned long data addresses from the 32-bit ARM implementation. In do_alignment_ldmstm(), nr_regs is an unsigned int holding the transfer size. The function uses the same address addition for both transfer directions, negating nr_regs first for a decrementing LDM or STM. The 32-bit negation wraps before the addition, so the handler adds nearly 4 GiB instead of subtracting the transfer size. The resulting address lies outside the compat task's address space, so decrementing LDM/STM emulation fails, while incrementing forms work. For example, a backwards-moving copy routine using decrementing LDM/STM can take an alignment fault when called with unaligned pointers. The compat handler should emulate the transfer, but this bug instead causes SIGBUS. The offset negated in do_alignment_finish_ldst() is offset_union.un, which is already unsigned long and does not have this width mismatch. Make nr_regs unsigned long so its negation and the address arithmetic use the same width. Fixes: 3fc24ef32d3b ("arm64: compat: Implement misalignment fixups for multiword loads") Cc: stable@vger.kernel.org Suggested-by: Arnd Bergmann Assisted-by: Codex:gpt-5.6-sol Signed-off-by: Karl Mehltretter Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/compat_alignment.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/arm64/kernel/compat_alignment.c +++ b/arch/arm64/kernel/compat_alignment.c @@ -114,8 +114,8 @@ do_alignment_ldrdstrd(unsigned long addr static int do_alignment_ldmstm(unsigned long addr, u32 instr, struct pt_regs *regs) { - unsigned int rd, rn, nr_regs, regbits; - unsigned long eaddr, newaddr; + unsigned int rd, rn, regbits; + unsigned long eaddr, newaddr, nr_regs; unsigned int val; /* count the number of registers in the mask to be transferred */