Since the commit 2b0e86cc5de6 ("powerpc/fsl_booke/32: implement KASLR
infrastructure"), the powerpc system is ready to support KASLR.
To reduces the risk of invalidating address randomization, don't print the
EIP/LR hex values in dump_stack() and show_regs().

This patch follows x86 and arm64's lead:
    commit a25ffd3a6302a6 ("arm64: traps: Don't print stack or raw
     PC/LR values in backtraces")
    commit bb5e5ce545f203 ("x86/dumpstack: Remove kernel text
     addresses from stack dump")

Signed-off-by: Xiaoming Ni <nixiaom...@huawei.com>
---
 arch/powerpc/kernel/process.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index a66f435dabbf..913cf1ea702e 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1455,8 +1455,8 @@ static void __show_regs(struct pt_regs *regs)
 {
        int i, trap;
 
-       printk("NIP:  "REG" LR: "REG" CTR: "REG"\n",
-              regs->nip, regs->link, regs->ctr);
+       printk("NIP: %pS LR: %pS CTR: "REG"\n",
+              (void *)regs->nip, (void *)regs->link, regs->ctr);
        printk("REGS: %px TRAP: %04lx   %s  (%s)\n",
               regs, regs->trap, print_tainted(), init_utsname()->release);
        printk("MSR:  "REG" ", regs->msr);
@@ -1493,8 +1493,8 @@ static void __show_regs(struct pt_regs *regs)
         * above info out without failing
         */
        if (IS_ENABLED(CONFIG_KALLSYMS)) {
-               printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
-               printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
+               printk("NIP %pS\n", (void *)regs->nip);
+               printk("LR %pS\n", (void *)regs->link);
        }
 }
 
@@ -2160,8 +2160,8 @@ void show_stack(struct task_struct *tsk, unsigned long 
*stack,
                newsp = stack[0];
                ip = stack[STACK_FRAME_LR_SAVE];
                if (!firstframe || ip != lr) {
-                       printk("%s["REG"] ["REG"] %pS",
-                               loglvl, sp, ip, (void *)ip);
+                       printk("%s ["REG"] %pS",
+                               loglvl, sp, (void *)ip);
                        ret_addr = ftrace_graph_ret_addr(current,
                                                &ftrace_idx, ip, stack);
                        if (ret_addr != ip)
-- 
2.27.0

Reply via email to