Arm Linux Kernel Hacks

rousalome.egloos.com

포토로그 Kernel Crash


통계 위젯 (화이트)

11105
637
415734


[Linux][Kernel]vmalloc - debugging(1) [Linux][Kernel] MM



리눅스 커널(Linux Kernel) 드라이버에서 vmalloc 아주 많이 쓰거든요.
그래서 디버깅할 일이 많아요.

자, 이제 vmap_area_list 변수 T32로 올려서 좀 들여다 볼까요?
  (static struct list_head) [D:0xC124E630] vmap_area_list = (
    (struct list_head *) [D:0xC124E630] next = 0xDE8026D8,
    (struct list_head *) [D:0xC124E634] prev = 0xDD85F258)

링크드 리스트이니 좀 T32의 비주얼 속성을 좀 써볼께요.
(출처: http://rousalome.egloos.com/9964132)

참 항목이 많네요.
do _fake_list_sym.cmm 0xC124E630
  0x0 (0)|  [C:0xC124E630] (
         |    [C:0xC124E630] next = 0xDE8026D8,
         |    [C:0xC124E634] prev = 0xDD85F258),
  0x1 (1)|  [C:0xDE8026D8] (
         |    [C:0xDE8026D8] next = 0xDE802798,
         |    [C:0xDE8026DC] prev = 0xC124E630),
  0x2 (2)|  [C:0xDE802798] (
         |    [C:0xDE802798] next = 0xDE80AF18,
         |    [C:0xDE80279C] prev = 0xDE8026D8),
  0x3 (3)|  [C:0xDE80AF18] (
         |    [C:0xDE80AF18] next = 0xDE80B858,
         |    [C:0xDE80AF1C] prev = 0xDE802798),
//snip
114 (276)|  [C:0xDE1F5558] (
         |    [C:0xDE1F5558] next = 0xDE1F6C18,
         |    [C:0xDE1F555C] prev = 0xDE1FE018),
115 (277)|  [C:0xDE1F6C18] (
         |    [C:0xDE1F6C18] next = 0xDE1F6B58,
         |    [C:0xDE1F6C1C] prev = 0xDE1F5558),

276번째 멤버를 좀 볼까요?
아래 T32 테크닉을 써서 container_of 매크로를 써 볼께요.
(http://rousalome.egloos.com/9963702)


각각 멤버를 해석해볼까요?
[1],[2]: vmalloc으로 쓰는 메모리 공간에에요.
0xE0DF2000-0xE0AF1000 = 0x301000 음, 0x301000 공간을 쓰고 있네요.         

[3]: struct vm_struct.flags가 0x2이니 vmalloc() 함수로 호출했다는 흔적을 알려주네요.
#define VM_ALLOC 0x00000002 /* vmalloc() */

[4]: 이 vmalloc()을 호출한게 어떤 놈인 지 알려줘요. MMProfileInitBuffer+0xC0
T32로 이렇게 쳐보면 소스 라인과 소스 이름을 알 수 있어요.
symbol.list.line MMProfileInitBuffer+0xC0
 |.droid/kernel/drivers/misc/pompeii/mmp/src/mmprofile.c|\308--0            |   prelim.| \\vmlinux\mmprofile\MMProfileInitBuffer+0xC0

v.v %s %t %h %y container_of(0xDE1F6C18,struct vmap_area,list) 
  (struct vmap_area *) container_of(0xDE1F6C18,struct vmap_area,list) = 0xDE1F6C00 = __b
    (long unsigned int) va_start = 0xE0AF1000,  //<<--[1]
    (long unsigned int) va_end = 0xE0DF2000, //<<--[2]
    (long unsigned int) flags = 0x4,
    (struct rb_node) rb_node = ((long unsigned int) __rb_parent_color = 0xDE1FE0CD, (str
    (struct list_head) list = ((struct list_head *) next = 0xDE1F6B58 = __bss_stop+0x1C9
    (struct list_head) purge_list = ((struct list_head *) next = 0x6B6B6B6B = , (struct
    (struct vm_struct *) vm = 0xDE1F6300 = __bss_stop+0x1C96C408 -> (
      (struct vm_struct *) next = 0x0 = ,
      (void *) addr = 0xE0AF1000 = __bss_stop+0x1F267108,
      (long unsigned int) size = 0x00301000,
      (long unsigned int) flags = 0x2,  //<<--[3]
      (struct page * *) pages = 0xDE1A4000 = __bss_stop+0x1C91A108,
      (unsigned int) nr_pages = 0x0300,
      (phys_addr_t) phys_addr = 0x0,
      (void *) caller = 0xC039DE30 = MMProfileInitBuffer+0xC0), //<<--[4]

다음에는 vmalloc 메모리 leak에 대해서 살펴보려고 해요.


# Reference: For more information on 'Linux Kernel';

디버깅을 통해 배우는 리눅스 커널의 구조와 원리. 1

디버깅을 통해 배우는 리눅스 커널의 구조와 원리. 2






핑백

덧글

댓글 입력 영역