From nobody Mon Sep 28 08:04:50 2026 Received: from oss.cyber.gouv.fr (oss.cyber.gouv.fr [51.159.188.251]) (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 6420217A586 for ; Mon, 24 Aug 2026 20:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.159.188.251 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787603927; cv=none; b=aBzlJXMe92G9FC+bKs5ORCfNvSu+zSQGefWEY6iSxajJrnJIeQ8UywlXBUq1E+ZXrWHPQGHwbOzrKVKiP1F+gRpXrgSSkcs/Dxf1esRzvqE5fSsdlBSYzn7N1Y+K+F/8jOs5osE8onk37pmH47CLn6Re7JHI1ISbMDiu9NjMeU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787603927; c=relaxed/simple; bh=p9FWgVSu/LXlktFq2u8UJHNW3cBbnYzgpxpH7frFw4k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=g2f5LvRlyOG6UN4zfBKW9tZ0QSfNVjYqxUPoKseVMGmbN2qyKpzeubfSIFm9UJt2jMGW/I+1Syz84S1TL/TZvG5Ev8GeShEWoaKfav+VA3/IWKewaHYYydfiGqvjXrush60vi3DB4964Comz/7eEUDPdUHUwi+szJma0q5n/Lwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.cyber.gouv.fr; spf=pass smtp.mailfrom=oss.cyber.gouv.fr; dkim=pass (2048-bit key) header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.b=hgEpTsEE; arc=none smtp.client-ip=51.159.188.251 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.cyber.gouv.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.cyber.gouv.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oss.cyber.gouv.fr header.i=@oss.cyber.gouv.fr header.b="hgEpTsEE" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=oss.cyber.gouv.fr; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IrwYsB/cvJROppYg40sjAVcDPzEozjwDIQ9eN23y38M=; b=hgEpTsEEXwqTdASOSbcRyqt2PO I4FkdIhsXufUAEpcUGFdSQw/c2aREDTg5seTKAQHXuS2cjPnggg3fmnjvGQtpMltGMkMfyA47Igzd AgvqWGGIgh9dOfVRUbwYRSr+n/5O41JArJHl6u6LZjdN5MT/4UcGUEYdkgCNoN0+yQ5q9tcY2gRsk o7icrvVekz6ZlYhLIThL+WbZGx/TRtkotuxxRH8y8ZX9WtujVcHhTI1yFYTr9HjMur02T5Z4fKWyH 9YGgw7wa4kDnqWO4PjkW2OEhaEhOIho5SvcJob9k91/XgOIjhcjp0qsJQ7cMcleRJLGFup2WzKgtz aXUEF2Hg==; Received: from [151.115.150.205] (port=47050 helo=gepetto..) by pf-012.whm.fr-par.scw.cloud with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.5) (envelope-from ) id 1wybRF-0000000DXTc-34iK; Mon, 24 Aug 2026 22:38:37 +0200 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= To: Vineet Gupta Cc: linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= Subject: [PATCH] ARC: check user addresses in unaligned access emulation Date: Mon, 24 Aug 2026 20:37:41 +0000 Message-ID: <20260824203740.3689400-2-Jeremy.Jean@oss.cyber.gouv.fr> X-Mailer: git-send-email 2.47.3 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 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - pf-012.whm.fr-par.scw.cloud X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - oss.cyber.gouv.fr X-Get-Message-Sender-Via: pf-012.whm.fr-par.scw.cloud: authenticated_id: jeremy.jean@oss.cyber.gouv.fr X-Authenticated-Sender: pf-012.whm.fr-par.scw.cloud: jeremy.jean@oss.cyber.gouv.fr X-Source: X-Source-Args: X-Source-Dir: ARC700 raises an alignment exception before checking access permissions. Consequently, a userspace load or store using a misaligned kernel address reaches misaligned_fixup() before the processor rejects it. misaligned_fixup() decodes the instruction and repeats the access using byte loads or stores. These accesses run in kernel mode, and exception tables only handle accesses that fault. A mapped kernel address is therefore read or written with supervisor permissions. Use access_ok() to reject addresses outside the user range before calling the helpers. Check the whole 2- or 4-byte range and use the checked address for the emulated operation. Fixes: 2e651ea1596b ("ARC: Unaligned access emulation") Assisted-by: Codex:gpt-daybreak-blue Signed-off-by: J=C3=A9r=C3=A9my Jean --- arch/arc/kernel/unaligned.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/arch/arc/kernel/unaligned.c b/arch/arc/kernel/unaligned.c index 3b2d8b1bd271..f6079dc89a6d 100644 --- a/arch/arc/kernel/unaligned.c +++ b/arch/arc/kernel/unaligned.c @@ -133,6 +133,8 @@ int no_unaligned_warning __read_mostly =3D 1; /* Only 1= warning by default */ static void fixup_load(struct disasm_state *state, struct pt_regs *regs, struct callee_regs *cregs) { + unsigned long address; + unsigned int size; int val; =20 /* register write back */ @@ -143,10 +145,15 @@ static void fixup_load(struct disasm_state *state, st= ruct pt_regs *regs, state->src2 =3D 0; } =20 + address =3D state->src1 + state->src2; + size =3D state->zz ? 2 : 4; + if (!access_ok((void __user *)address, size)) + goto fault; + if (state->zz =3D=3D 0) { - get32_unaligned_check(val, state->src1 + state->src2); + get32_unaligned_check(val, address); } else { - get16_unaligned_check(val, state->src1 + state->src2); + get16_unaligned_check(val, address); =20 if (state->x) val =3D (val << 16) >> 16; @@ -163,6 +170,9 @@ fault: state->fault =3D 1; static void fixup_store(struct disasm_state *state, struct pt_regs *regs, struct callee_regs *cregs) { + unsigned long address; + unsigned int size; + /* register write back */ if ((state->aa =3D=3D 1) || (state->aa =3D=3D 2)) { set_reg(state->wb_reg, state->src2 + state->src3, regs, cregs); @@ -181,11 +191,16 @@ static void fixup_store(struct disasm_state *state, s= truct pt_regs *regs, } } =20 + address =3D state->src2 + state->src3; + size =3D state->zz ? 2 : 4; + if (!access_ok((void __user *)address, size)) + goto fault; + /* write fix-up */ if (!state->zz) - put32_unaligned_check(state->src1, state->src2 + state->src3); + put32_unaligned_check(state->src1, address); else - put16_unaligned_check(state->src1, state->src2 + state->src3); + put16_unaligned_check(state->src1, address); =20 return; =20 --=20 2.47.3