]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm64: poe: fix stale POR_EL0 values for ptrace
authorJoey Gouly <joey.gouly@arm.com>
Tue, 27 Jan 2026 13:39:26 +0000 (13:39 +0000)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:21:18 +0000 (07:21 -0500)
[ Upstream commit 1f3b950492db411e6c30ee0076b61ef2694c100a ]

If a process wrote to POR_EL0 and then crashed before a context switch
happened, the coredump would contain an incorrect value for POR_EL0.

The value read in poe_get() would be a stale value left in thread.por_el0.  Fix
this by reading the value from the system register, if the target thread is the
current thread.

This matches what gcs/fpsimd do.

Fixes: 175198199262 ("arm64/ptrace: add support for FEAT_POE")
Reported-by: David Spickett <david.spickett@arm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm64/kernel/ptrace.c

index fd1ba43f2005a90618ab39f8da73e156a3e3a8cd..2e9ce5a45ed2daacbad2bb7196bc7b6f63754c49 100644 (file)
@@ -1458,6 +1458,9 @@ static int poe_get(struct task_struct *target,
        if (!system_supports_poe())
                return -EINVAL;
 
+       if (target == current)
+               current->thread.por_el0 = read_sysreg_s(SYS_POR_EL0);
+
        return membuf_write(&to, &target->thread.por_el0,
                            sizeof(target->thread.por_el0));
 }