From nobody Fri Oct 3 06:36:48 2025 Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) (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 2C9D82EB5B3; Thu, 4 Sep 2025 22:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.133.4.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757023430; cv=none; b=eky7l5ybuexiTwcxGXOGJkleDakt8yW+7aW6B2A5KfpgPhiPwwllVKC/MFBaapMziAZIFasVKcZ3iqfiWvaos6iekhYV+IL7vZ1I6ZWF/Ugqwm88L9mehy8OB+b471kIMNR3uoyZc71n6/6YpVsmTAuKy5v5LUD93rvrdzwIngo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757023430; c=relaxed/simple; bh=ef/KmXAU5twJnvrbNwO81lp483y8IFKk+ht1SJzwdcs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z2Oe2RiW0KHHJqFV0OlqrX4yYehJy1wzYZy4K7GBzEss64z4EOfR+K4nKoa5Fo0+hpoutQUdOF0mfFLbUiZVLFCL3qyr0Ul+YaocXDv/L/WSeDB1ZLYfeSdUqItMPWyt0TF7ed9S3oPh1rCciiKhDRB2wGb0Ve7DsysxiPvROYE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mkarcher.dialup.fu-berlin.de; spf=pass smtp.mailfrom=zedat.fu-berlin.de; dkim=pass (2048-bit key) header.d=fu-berlin.de header.i=@fu-berlin.de header.b=NaQVCVG7; arc=none smtp.client-ip=130.133.4.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mkarcher.dialup.fu-berlin.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zedat.fu-berlin.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fu-berlin.de header.i=@fu-berlin.de header.b="NaQVCVG7" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fu-berlin.de; s=fub01; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:From: Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:In-Reply-To: References; bh=oS6pbq8B7+OURvadlkC+ImR86L0693Iz+IdGLSCm81E=; t=1757023427; x=1757628227; b=NaQVCVG7p6WcnfR2CTkH5bhZZZeohtrR/JHXnCnGtg0qTi7lEREPU9Rs0r4ED 99ixHzYrRiZGBj3PizRSaD/4qtE7qnRcVCyNFYqvpaORaim065mkFU76vclk3ZGV+Bm4FWeZAMbLC 0yM7s9ZpetQ1pyqAnR4HzH+63pIhBjLHM4pjzru2GqKsVasoqrPegXz8KQuNHiarMY3nO2UBHy+Zd rcg/7+LxDLPIIsh7/NWDGvps1owfx2L9jP7TpxeoDRNRuQptkGzGaEbrYitNwpFP8ipWUuMCC4L1P 89TAZUQxXX7ZoKbJvydGES4Q/XCmHvOn3Bk8Bauz3VEs/eMK1w==; Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.98) with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1uuI3V-00000000z7J-1bAx; Fri, 05 Sep 2025 00:03:45 +0200 Received: from 89-103-142-46.pool.kielnet.net ([46.142.103.89] helo=Geist14.) by inpost2.zedat.fu-berlin.de (Exim 4.98) with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1uuI3V-00000002DJL-0nAc; Fri, 05 Sep 2025 00:03:45 +0200 From: Michael Karcher Date: Fri, 05 Sep 2025 00:03:31 +0200 Subject: [PATCH v4 2/5] sparc: fix accurate exception reporting in copy_{from_to}_user for UltraSPARC III Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250905-memcpy_series-v4-2-1ca72dda195b@mkarcher.dialup.fu-berlin.de> References: <20250905-memcpy_series-v4-0-1ca72dda195b@mkarcher.dialup.fu-berlin.de> In-Reply-To: <20250905-memcpy_series-v4-0-1ca72dda195b@mkarcher.dialup.fu-berlin.de> To: Andreas Larsson Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Karcher , John Paul Adrian Glaubitz , Anthony Yznaga , =?utf-8?q?Ren=C3=A9_Rebe?= X-Mailer: b4 0.14.2 X-Original-Sender: kernel@mkarcher.dialup.fu-berlin.de X-ZEDAT-Hint: PO Anthony Yznaga tracked down that a BUG_ON in ext4 code with large folios enabled resulted from copy_from_user() returning impossibly large values greater than the size to be copied. This lead to __copy_from_iter() returning impossible values instead of the actual number of bytes it was able to copy. The BUG_ON has been reported in https://lore.kernel.org/r/b14f55642207e63e907965e209f6323a0df6dcee.camel@ph= ysik.fu-berlin.de The referenced commit introduced exception handlers on user-space memory references in copy_from_user and copy_to_user. These handlers return from the respective function and calculate the remaining bytes left to copy using the current register contents. The exception handlers expect that %o2 has already been masked during the bulk copy loop, but the masking was performed after that loop. This will fix the return value of copy_from_user and copy_to_user in the faulting case. The behaviour of memcpy stays unchanged. Fixes: ee841d0aff64 ("sparc64: Convert U3copy_{from,to}_user to accurate ex= ception reporting.") Tested-by: John Paul Adrian Glaubitz # on Su= n Netra 240 Reviewed-by: Anthony Yznaga Tested-by: Ren=C3=A9 Rebe # on UltraSparc III+ and Ult= raSparc IIIi Signed-off-by: Michael Karcher --- arch/sparc/lib/U3memcpy.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sparc/lib/U3memcpy.S b/arch/sparc/lib/U3memcpy.S index 9248d59c734ce200f1f55e6d9913277f18715a87..bace3a18f836f1428ae0ed72b27= aa1e00374089e 100644 --- a/arch/sparc/lib/U3memcpy.S +++ b/arch/sparc/lib/U3memcpy.S @@ -267,6 +267,7 @@ FUNC_NAME: /* %o0=3Ddst, %o1=3Dsrc, %o2=3Dlen */ faligndata %f10, %f12, %f26 EX_LD_FP(LOAD(ldd, %o1 + 0x040, %f0), U3_retl_o2) =20 + and %o2, 0x3f, %o2 subcc GLOBAL_SPARE, 0x80, GLOBAL_SPARE add %o1, 0x40, %o1 bgu,pt %XCC, 1f @@ -336,7 +337,6 @@ FUNC_NAME: /* %o0=3Ddst, %o1=3Dsrc, %o2=3Dlen */ * Also notice how this code is careful not to perform a * load past the end of the src buffer. */ - and %o2, 0x3f, %o2 andcc %o2, 0x38, %g2 be,pn %XCC, 2f subcc %g2, 0x8, %g2 --=20 2.50.1