Ticket #11131: Added-check-to-ensure-KDL-does-not-fault-when-printing-backtrace.patch

File Added-check-to-ensure-KDL-does-not-fault-when-printing-backtrace.patch, 2.4 KB (added by arvindsraj, 6 years ago)
  • headers/private/kernel/arch/arm/arch_kernel.h

    From 4c82e110bbaad211fcc6dda8698041ca97017d10 Mon Sep 17 00:00:00 2001
    From: Arvind S Raj <sraj.arvind@gmail.com>
    Date: Fri, 15 Aug 2014 00:27:39 +0530
    Subject: [PATCH] Added check to ensure KDL does not include frames beyond
     kernel entry in the backtrace. This prevents KDL from faulting when printing
     backtrace on ARM.
    
    ---
     headers/private/kernel/arch/arm/arch_kernel.h |  2 +-
     src/system/boot/arch/arm/arch_mmu.cpp         |  2 +-
     src/system/kernel/arch/arm/arch_debug.cpp     | 19 +++++++++----------
     3 files changed, 11 insertions(+), 12 deletions(-)
    
    diff --git a/headers/private/kernel/arch/arm/arch_kernel.h b/headers/private/kernel/arch/arm/arch_kernel.h
    index 766ab42..9c8723b 100644
    a b  
    99
    1010// memory layout
    1111#define KERNEL_BASE 0x80000000
    12 #define KERNEL_SIZE 0x80000000
     12#define KERNEL_SIZE 0x800000
    1313#define KERNEL_TOP  (KERNEL_BASE + (KERNEL_SIZE - 1))
    1414
    1515/*
  • src/system/boot/arch/arm/arch_mmu.cpp

    diff --git a/src/system/boot/arch/arm/arch_mmu.cpp b/src/system/boot/arch/arm/arch_mmu.cpp
    index 758a1f3..7e2f44a 100644
    a b TODO:  
    5959
    6060
    6161// 8 MB for the kernel, kernel args, modules, driver settings, ...
    62 static const size_t kMaxKernelSize = 0x800000;
     62static const size_t kMaxKernelSize = KERNEL_SIZE;
    6363
    6464// Base address for loader
    6565static const size_t kLoaderBaseAddress = KERNEL_LOAD_BASE + kMaxKernelSize;
  • src/system/kernel/arch/arm/arch_debug.cpp

    diff --git a/src/system/kernel/arch/arm/arch_debug.cpp b/src/system/kernel/arch/arm/arch_debug.cpp
    index 1832ca2..985ce7c 100644
    a b already_visited(uint32 *visited, int32 *_last, int32 *_num, uint32 fp)  
    5656static status_t
    5757get_next_frame(addr_t fp, addr_t *next, addr_t *ip)
    5858{
    59     if (fp != 0) {
    60             addr_t _fp = *(((addr_t*)fp) -3);
    61             addr_t _sp = *(((addr_t*)fp) -2);
    62             addr_t _lr = *(((addr_t*)fp) -1);
    63             addr_t _pc = *(((addr_t*)fp) -0);
     59    addr_t _fp = *(((addr_t*)fp) -3);
     60    addr_t _sp = *(((addr_t*)fp) -2);
     61    addr_t _lr = *(((addr_t*)fp) -1);
     62    addr_t _pc = *(((addr_t*)fp) -0);
    6463
    65         *ip = (_fp != 0) ? _lr : _pc;
    66         *next = _fp;
    67 
    68         return B_OK;
     64    if (_lr > KERNEL_TOP) {
     65        return B_BAD_ADDRESS;
    6966    }
     67    *ip = (_fp != 0) ? _lr : _pc;
     68    *next = _fp;
    7069
    71     return B_BAD_VALUE;
     70    return B_OK;
    7271}
    7372
    7473