From nobody Mon Sep 28 13:18:54 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 7281E471D09 for ; Fri, 21 Aug 2026 10:30:51 +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=1787308256; cv=none; b=K1Sw5O7a7L5Tw50EcZy3uuFjjdkDv4mynGvfwRySSivcd1hjakrb1ss3+ReSwVT6e9iEuYU2sTkJ/wG5AYSrFHtIBCtySlQ6ep3Hz8PSSkBPdKFlCQ9uoj2SYsbQKspJgEjEelj94LnIQiuGrqRUMFUG6Uh1nr7q4j7X1EsUTTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787308256; c=relaxed/simple; bh=ZVPfxoYGqdgU83A4ddpOzacHTNgl0BoVzFbwrBEueXs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=s7SvFZgLem+7AbUUpzR7JwLuwladjQnLXLeO2uZUmCU8vqVhz+gOPVAEobaBj0BkanmiWBzw+M36i5ToQhcet/NvNG29A/TfOiuX/txC/72I55RcFjZpuF7sfok7GGdk5lpG6l6TY0S73ohzPxg/ujrNHGAZUpaLk0Fmgm+JToE= 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=iyjOWI6e; 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="iyjOWI6e" 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=gSPViQw9E+KoUS82R1hhz5h8rY0HBX5qy6LN2asin60=; b=iyjOWI6eibuF3XAdryLryx6xgA IMVTCN8eksnCSL5KfZoCPbphQ2iCsEJeJ1xYO0ZpKf/KPa05lC+052RqMHZS7FOPs5kqZbqSfJmfK QftkikC3wIevD2sFflxqi97S2y9iY0VZWnubnyhC9JfzQTiPW8wIu5s7uGxPXEjeRRu0mWFZfSAT/ Yk1olnVnE2WM8YxKtPlQlB8vv25JhBejvHQY0N7Z9ltpzEICFF71D6yEHPbDuDuOx/9+cuXXUnNFb zdzTqgpD3YzlLx2maUHhCiEOEvVhmmGu+SdmvPiehxInjD3IUtJgqBMMwu/SgGoRcdxovPxH0N4n5 B5lcBpEA==; Received: from [151.115.150.205] (port=55364 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 1wxMWL-00000004rwK-1dZP; Fri, 21 Aug 2026 12:30:45 +0200 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= To: Michal Simek , Oleg Nesterov Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= Subject: [PATCH] microblaze: prevent ptrace writes to MSR and pt_mode Date: Fri, 21 Aug 2026 10:30:27 +0000 Message-ID: <20260821103026.3627292-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: arch_ptrace() accepts PTRACE_POKEUSR for every aligned offset below PT_SIZE. This includes the saved machine status register and pt_mode, which are kernel-owned execution state rather than general registers. On return from an exception, rtbd copies MSR_UMS to the live MSR_UM bit. An unprivileged same-UID tracer can therefore clear MSR_UMS in its tracee's saved register frame and make the tracee resume in supervisor mode. pt_mode also controls whether later entry paths classify the frame as kernel or user state. Reject PTRACE_POKEUSR writes to both fields while retaining read access. Fixes: 2b4384542691 ("microblaze_v8: ptrace support") Assisted-by: Codex:gpt-5 Signed-off-by: J=C3=A9r=C3=A9my Jean --- arch/microblaze/kernel/ptrace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/microblaze/kernel/ptrace.c b/arch/microblaze/kernel/ptrac= e.c index 236264e932d6..ac1f0503216b 100644 --- a/arch/microblaze/kernel/ptrace.c +++ b/arch/microblaze/kernel/ptrace.c @@ -101,6 +101,9 @@ long arch_ptrace(struct task_struct *child, long reques= t, } else { rval =3D -EIO; } + } else if (request =3D=3D PTRACE_POKEUSR && + (addr =3D=3D PT_MSR || addr =3D=3D PT_MODE)) { + rval =3D -EIO; } else if (addr < PT_SIZE && (addr & 0x3) =3D=3D 0) { microblaze_reg_t *reg_addr =3D reg_save_addr(addr, child); if (request =3D=3D PTRACE_PEEKUSR) --=20 2.47.3