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 60E033B640A; Sat, 28 Feb 2026 17:38:51 +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=1772300331; cv=none; b=gGsvFz/8FXZo4p03zjoqm7M2mTBPoYfwJ4j2fCPNPM8w2QXMP+G2/+n6vbQ36Pr3M8JWPrhosnH1Q0J0xdHh3tBhkXNsEH476FUSbbMjWSnBMuPPPdyC2cGxS1VrvBc45HmvFRCcR7wt/dXcOvpaXszDKMZ+DZWb6cUvlOamEmw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300331; c=relaxed/simple; bh=ghFaaLmJj1iPLJhplCjQVJwlTyugZcyZZUzRtfbzkyk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DNYF9VyRFj9iEjx5OhJ00T+T84DH+gwRRupjoVa1hAWoAhYIiyCekC9NeZcTCoGHKJDU47TUOfYME0mBX3HbUnK8I0yqUvXY2dQTFqBVJMcViFOethVU5+z9Awlnc2fZIfj/xCi6fZWnp0LUftUupyYsfQLAVPI9ULqKKE6pxY0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eL8RNLzo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eL8RNLzo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CFB6C19424; Sat, 28 Feb 2026 17:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300331; bh=ghFaaLmJj1iPLJhplCjQVJwlTyugZcyZZUzRtfbzkyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eL8RNLzo5jcpaNmrGe+3E9NdCDw+ZAoHkqueHgsX0U9ukBZpOl+ffTGsVWwsfVlFA RHRL7uOZBJvBFOjnyuufzzYSFpxYldR8FEn2cNzld48Xu/KSwaDFj4TLE39ZhKDIAk klf1SKy/LnjTmJch2BYsDFsqlj7ZZIKdVIX8xrFH4DUwhDfVy0nDC12SYUQ+IcKUrn u0QHxDyrO64URhrxXpkCpy/l5kozb31kpQMEhsG/cDw3PI2yJCaJJYBq5dCrIWLAvx XWGzRP8YTKtDtM6G2ujWSoe7xtZ2ZsrQy9JVKBs1h8yID93RWN92edKN4SpxMkLArK aqKlX1pN+g4KA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Palmer , Greg Ungerer , Sasha Levin Subject: [PATCH 6.19 363/844] m68k: nommu: fix memmove() with differently aligned src and dest for 68000 Date: Sat, 28 Feb 2026 12:24:36 -0500 Message-ID: <20260228173244.1509663-364-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Daniel Palmer [ Upstream commit 590fe2f46c8698bb758f9002cb247ca10ce95569 ] 68000 has different alignment needs to 68020+. memcpy() checks if the destination is aligned and does a smaller copy to fix the alignment and then critically for 68000 it checks if the source is still unaligned and if it is reverts to smaller copies. memmove() does not currently do the second part and malfunctions if one of the pointers is aligned and the other isn't. This is apparently getting triggered by printk. If I put breakpoints into the new checks added by this commit the first hit looks like this: memmove (n=205, src=0x2f3971 , dest=0x2f3980 ) at arch/m68k/lib/memmove.c:82 Signed-off-by: Daniel Palmer Signed-off-by: Greg Ungerer Signed-off-by: Sasha Levin --- arch/m68k/lib/memmove.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/m68k/lib/memmove.c b/arch/m68k/lib/memmove.c index 6519f7f349f66..e33f00b02e4c0 100644 --- a/arch/m68k/lib/memmove.c +++ b/arch/m68k/lib/memmove.c @@ -24,6 +24,15 @@ void *memmove(void *dest, const void *src, size_t n) src = csrc; n--; } +#if defined(CONFIG_M68000) + if ((long)src & 1) { + char *cdest = dest; + const char *csrc = src; + for (; n; n--) + *cdest++ = *csrc++; + return xdest; + } +#endif if (n > 2 && (long)dest & 2) { short *sdest = dest; const short *ssrc = src; @@ -66,6 +75,15 @@ void *memmove(void *dest, const void *src, size_t n) src = csrc; n--; } +#if defined(CONFIG_M68000) + if ((long)src & 1) { + char *cdest = dest; + const char *csrc = src; + for (; n; n--) + *--cdest = *--csrc; + return xdest; + } +#endif if (n > 2 && (long)dest & 2) { short *sdest = dest; const short *ssrc = src; -- 2.51.0