From d09f72c453f045009224111c765f7dd7d5f27dae Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Thu, 3 Sep 2015 03:12:33 +0200 Subject: [PATCH] Kernel: improve stacktrace printing - corrupt stack traces could trigger a kernel panic; - output consistency and spelling. Change-Id: I04c9ac7db77593d6e837a28c83f1734adc8d9da7 --- minix/kernel/arch/i386/exception.c | 4 ++-- minix/kernel/arch/i386/memory.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/minix/kernel/arch/i386/exception.c b/minix/kernel/arch/i386/exception.c index 08e73e419..3317ebbbd 100644 --- a/minix/kernel/arch/i386/exception.c +++ b/minix/kernel/arch/i386/exception.c @@ -314,7 +314,7 @@ static void proc_stacktrace_execute(struct proc *whichproc, reg_t v_bp, reg_t pc } printf("0x%lx ", (unsigned long) v_pc); if(v_hbp != 0 && v_hbp <= v_bp) { - printf("(hbp %lx ?)", v_hbp); + printf("(hbp 0x%lx ?)", v_hbp); break; } v_bp = v_hbp; @@ -335,7 +335,7 @@ void proc_stacktrace(struct proc *whichproc) u32_t use_bp; if(whichproc->p_seg.p_kern_trap_style == KTS_NONE) { - printf("WARNING: stacktrace of running proecss\n"); + printf("WARNING: stacktrace of running process\n"); } switch(whichproc->p_seg.p_kern_trap_style) { diff --git a/minix/kernel/arch/i386/memory.c b/minix/kernel/arch/i386/memory.c index 17a97dd84..b07d685f4 100644 --- a/minix/kernel/arch/i386/memory.c +++ b/minix/kernel/arch/i386/memory.c @@ -192,6 +192,10 @@ static int lin_lin_copy(struct proc *srcproc, vir_bytes srclinaddr, if(changed) reload_cr3(); + /* Check for overflow. */ + if (srcptr + chunk < srcptr) return EFAULT_SRC; + if (dstptr + chunk < dstptr) return EFAULT_DST; + /* Copy pages. */ PHYS_COPY_CATCH(srcptr, dstptr, chunk, addr);