이번에는 비트 플립으로 발생한 커널 패닉 코어 덤프 분석 과정을 소개합니다.
 
다음은 T32로 커널 패닉이 발생했을 때 잡은 콜스택입니다.
01 -000|machine_restart(?)
02 -001|arch_local_irq_enable(inline)
03 -001|panic(fmt = 0xC0EF195A)
04 -002|oops_end(inline)
05 -002|die(str = 0xC017409E, ?, err = -590234666)
06 -003|do_undefinstr(regs = 0xDCD1BCA8)
07 -004|__und_svc_fault(asm)
08  -->|exception
09 -005|profile_tick(type = -590234136)
10 -006|tick_sched_timer(timer = 0xC5B5B620)
11 -007|static_key_false(inline)
12 -007|trace_hrtimer_expire_exit(inline)
13 -007|__run_hrtimer(timer = 0xC5B5B620, now = 0xDCD1BD68)
14 -008|hrtimer_interrupt(?)
15 -009|timer_handler(inline)
16 -009|arch_timer_handler_virt(?, ?)
17 -010|static_key_false(inline)
18 -010|trace_irq_handler_exit(inline)
19 -010|handle_percpu_devid_irq(irq = 20, desc = 0xE1C08F00)
20 -011|generic_handle_irq(irq = 20)
21 -012|handle_IRQ(irq = 20, ?)
22 -013|gic_handle_irq(regs = 0xC5B5B620)
23 -014|__irq_svc(asm)
24  -->|exception
25 -015|open_check_o_direct(f = 0xDB621900)
26 -016|do_last(nd = 0xDCD1BF00, path = 0xDCD1BEC0, file = 0xDB621900, ?, opened = 0xDCD1BEBC, name = 0xC02057EC)
27 -017|path_openat(dfd = -100, ?, nd = 0xDCD1BF00, op = 0xDCD1BF78, flags = 65)  // /proc/32/status
28 -018|do_filp_open(dfd = -100, pathname = 0xD44BC000, op = 0xDCD1BF78, flags = 1)
29 -019|do_sys_open(dfd = -614328064, ?, flags = 131072, ?)
 
콜스택 정보로 보아 profile_tick() 함수에서 undefined instruction 익셉션이 발생했음을 알 수 있습니다.
07 -004|__und_svc_fault(asm)
08  -->|exception
09 -005|profile_tick(type = -590234136)
10 -006|tick_sched_timer(timer = 0xC5B5B620)
 
07번 째 줄을 보면 undefined instruction 익셉션 벡터인 __und_svc_fault 레이블을 볼 수 있습니다.
 
문제를 분석하기 위해 익셉션이 발생한 0xc0174084 주소 코드를 점검했습니다.
01 0xc0174084 <profile_handoff_task+0x24>:                 ; <UNDEFINED> instruction: 0x87bfd030
 /root/pi/kernel/kernel/profile.c: 154
02  0xc0174088 <profile_munmap>:    andeq   r0, r0, r0
 /root/pi/kernel/kernel/profile.c: 155
03 0xc017408c <profile_munmap+0x4>:        ldmdahi r7!, {r3, r4, r5, r6, r8, r12, sp, lr, pc}^
 
0xc0174084 주소에 있는 어셈블리 코드를 보니 <UNDEFINED> instruction:을 확인할 수 있습니다.
 
0xc0174084 주소에서 비트 플립으로 익셉션이 발생했음을 확인할 수 있었습니다.

+ Recent posts