]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/ptrace: Fix pointer dereferencing in regs_get_kernel_stack_nth()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 13 Jun 2025 15:53:04 +0000 (17:53 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 17 Jun 2025 16:15:25 +0000 (18:15 +0200)
The recent change which added READ_ONCE_NOCHECK() to read the nth entry
from the kernel stack incorrectly dropped dereferencing of the stack
pointer in order to read the requested entry.

In result the address of the entry is returned instead of its content.

Dereference the pointer again to fix this.

Reported-by: Will Deacon <will@kernel.org>
Closes: https://lore.kernel.org/r/20250612163331.GA13384@willie-the-truck
Fixes: d93a855c31b7 ("s390/ptrace: Avoid KASAN false positives in regs_get_kernel_stack_nth()")
Cc: stable@vger.kernel.org
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/include/asm/ptrace.h

index 62c0ab4a4b9de83b2f7635d693f4ccfff049dde0..0905fa99a31ee374265944b23e8b19263446c914 100644 (file)
@@ -265,7 +265,7 @@ static __always_inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *r
        addr = kernel_stack_pointer(regs) + n * sizeof(long);
        if (!regs_within_kernel_stack(regs, addr))
                return 0;
-       return READ_ONCE_NOCHECK(addr);
+       return READ_ONCE_NOCHECK(*(unsigned long *)addr);
 }
 
 /**