Sanitizer manzili - AddressSanitizer - Wikipedia

Sanitizer manzili (yoki ASan) tomonidan ochiq manbali dasturlash vositasi Google bu aniqlaydi xotira buzilishi xatolar kabi bufer toshib ketadi yoki a-ga kirish osilgan ko'rsatgich (bepul foydalanishdan keyin). AddressSanitizer asoslanadi kompilyator asbobsozlik va to'g'ridan-to'g'ri xaritada soya xotirasi. AddressSanitizer hozirda amalga oshirilmoqda Jiringlash (3.1 versiyasidan boshlab[1]) , GCC (4.8 versiyasidan boshlab[2]), Xkod (7.0 versiyasidan boshlab[3]) va MSVC (16.4 versiyasidan boshlab[4]). O'rtacha asboblar ishlash vaqtini taxminan 73% ga va xotiradan foydalanishni 240% ga oshiradi.[5]

Foydalanuvchilar

Xrom va Firefox ishlab chiquvchilar - AddressSanitizer-ning faol foydalanuvchilari;[6][7] vosita ushbu veb-brauzerlarda yuzlab xatolarni topdi.[8]Bir qator xatoliklar topildi FFmpeg[9]va FreeType.[10] The Linux yadrosi uchun AddressSanitizer-ni yoqdi x86-64 Linux versiyasi 4.0 ga binoan arxitektura.

KernelAddressSanitizer

The KernelAddressSanitizer (KASAN) Linux yadrosidagi dinamik xotira xatolarini aniqlaydi.[11] Yadro asboblari ta'minlovchi kompilyatorda alohida xususiyatni talab qiladi -fsanitize = yadro-manzil buyruq satri opsiyasi, chunki yadrolar oddiy dasturlar bilan bir xil manzil maydonidan foydalanmaydi.[12][13]

Misollar

To'plamdan keyin bepul foydalanish

1 // Tuzish uchun: g ++ -O -g -fsanitize = address heap-use-after-free.cc2 int asosiy(int arg, char **argv) {3   int *qator = yangi int[100];4   o'chirish [] qator;5   qaytish qator[arg];  // BOOM6 }
$ ./a.out==5587==ERROR: AddressSanitizer: 0x61400000fe44 manzilida hex-use-free-free on PC 0x47b55f bp 0x7ffc36b28200 sp 0x7ffc36b281f8READ on 4 size at 0x61400000fe44 thread T0 # 0 0xxbb T0 # 0 0xxbb .cc: 7 # 1 0x7f15cfe71b14 in __libc_start_main (/lib64/libc.so.6+0x21b14) # 2 0x47b44c in _start (/root/a.out+0x47b44c)0x61400000fe44 400 baytli mintaqada 4 bayt ichida joylashgan [0x6, 0x61400000ffd0) bu erda T0 ip bilan bo'shatilgan: # 0 0x465da9 operatorida delete [] (void *) (/root/a.out+0x465da9) # 1 0x47b529 in main /home/test/example_UseAfterFree.cc:6predient oldin T0 thread tomonidan ajratilgan. : # 0 0x465aa9 operatorida new [] (unsigned long) (/root/a.out+0x465aa9) # 1 0x47b51e in main /home/test/example_UseAfterFree.cc:5 XULOSA: AddressSanitizer: heap-use-free-free / home /test/example_UseAfterFree.cc:7 mainBoya vositasi atrofidagi soya baytlari: 0x0c287fff9f70: fa fa fa fa fa fa fa fa fa fa fa fa 0x0c287fff9f80: fa fa fa fa fa fa fa fa fa fa fa fa fa 0x0c287fff9f90: fa fa fa fa fa fa fa fa fa fa fa 0x0c287fff9fa0: fa fa fa fa fa fa fa fa 0 fa 0x0c287fff9fb0: fa fa fa Angliya Angliya Angliya Angliya Angliya Angliya Angliya Angliya Angliya Angliya FA fa => 0x0c287fff9fc0: fa fa fa fa fa fa fa fa [fd] fd fd fd fd fd fd fd 0x0c287fff9fd0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd FD FD FD fd fd fd fd fd fd fd fd fd fd fd fd fd 0x0c287fff9ff0: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa 0x0c287fffa000: fa fa fa fa fa fa fa fa fa fa fd 0x0c287fff9fe0 fd fa fa fa fa fa 0x0c287fffa010: fa fa fa fa fa fa fa fa fa fa fa fa fa soyada bayt afsonasi (bitta soyali bayt 8 ta dastur baytini ifodalaydi): Manzil: 00 Qisman manzil: 01 02 03 04 05 06 07 chap redzone: fa Heap o'ng redzone: fb Bo'sh bo'shashgan mintaqa: fd Stack chap redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack qisman redzone: f4 Qaytgandan keyin stack: f5 Stack foydalanish doirasidan keyin: f8 Globa l redzone: f9 Global boshlash tartibi: f6 Foydalanuvchi tomonidan zaharlangan: f7 ASan ichki: fe == 5587 == ABORTING

To'plangan bufer

1 // RUN: clang ++ -O -g -fsanitize =% t && ./a.out manzili2 int asosiy(int arg, char **argv) {3   int *qator = yangi int[100];4   qator[0] = 0;5   int res = qator[arg + 100];  // BOOM6   o'chirish [] qator;7   qaytish res;8 }
== 25372 == ERROR: AddressSanitizer: 0x61400000ffd4 manzilidagi heap-buffer-overflow at PC 0x0000004ddb59 bp 0x7fffea6005a0 sp 0x7fffea600598READ at 4 size at 0x61400000ffd4 thread T0 # 0 0xxmp6 400 baytli mintaqaning o'ng tomonida [0x61400000fe40,0x61400000ffd0) bu erda T0 ipi tomonidan ajratilgan: # 0 0x4536e1 operatorida delete [] (void *) # 1 0x46bfb9 in main /tmp/main.cpp:2:16

Stek-bufer-toshib ketish

1 // RUN: clang -O -g -fsanitize = manzil% t && ./a.out2 int asosiy(int arg, char **argv) {3   int stack_array[100];4   stack_array[1] = 0;5   qaytish stack_array[arg + 100];  // BOOM6 }
== 7405 == ERROR: AddressSanitizer: 0x7fff64740634 manzilida stack-buffer-overflow pc 0x46c103 bp 0x7fff64740470 sp 0x7fff64740468READ 0x7fff64740634 thread T0 # 0 0xxf664/64/mp3/64/06/06/06/06/06/06/06/06/3 436 ofsetda T0 magistralida # 0 0x46bfaf ichida main /tmp/example_StackOutOfBounds.cc:2 Ushbu ramkada 1 ta ob'ekt mavjud: [32, 432) 'stack_array' <== 436 ofsetdagi xotiraga kirish ushbu o'zgaruvchini to'ldiradi

Global-bufer-overflow

// RUN: clang -O -g -fsanitize =% t && ./a.out manziliint global_array[100] = {-1};int asosiy(int arg, char **argv) {  qaytish global_array[arg + 100];  // BOOM}
== 7455 == XATO: AdresSanitizer: 0x000000689b54 manzilida global 0x46bfd8 bp 0x7fff515e5ba0 sp 0x7fff515e5b98READ, 0x000000689b54 thread T0 # 0bb44 'global_array' global o'zgaruvchisining huquqi 'example_GlobalOutOfBounds.cc' dan (0x6899c0) 400 o'lchamdagi

Cheklovlar

AddressSanitizer ishga tushirilmagan xotirani o'qishni aniqlamaydi (lekin buni aniqlaydi MemorySanitizer[14]) va faqat qaytarib yuborilgandan keyin ba'zi xatolarni aniqlaydi.[15] Shuningdek, u xotira buzilishidagi barcha o'zboshimchaliklarni aniqlay olmaydi, shuningdek, tamsayt quyilishi / to'lib toshganligi sababli o'zboshimchalik bilan yozishdagi xatolarni ham (aniqlanmagan xatti-harakatlar bilan tamsayı xotira manzillarini o'chirishni hisoblash uchun ishlatilganda). Strukturalar va sinflardagi qo'shni tamponlar ortiqcha oqimdan himoyalanmagan, qisman orqaga qarab moslikni buzishining oldini olish uchun.[16]

Shuningdek qarang

Adabiyotlar

  1. ^ "LLVM 3.1 nashrining eslatmalari". LLVM. Olingan 8 fevral 2014.
  2. ^ "GCC 4.8 chiqarilishi to'g'risida eslatmalar". GCC. Olingan 8 fevral 2014.
  3. ^ "Sanitizer-manzil | Apple Tuzuvchi hujjatlari".
  4. ^ "Visual Studio 2019 versiyasi 16.4 versiyasi uchun eslatmalar". Microsoft. Olingan 6 noyabr 2020.
  5. ^ Konstantin Serebryany; Derek Bruening; Aleksandr Potapenko; Dmitriy Vyukov. "AddressSanitizer: tezkor manzilni sog'lomlashtirishni tekshiruvchi" (PDF). Yillik Texnik Konferentsiyadagi 2012 yil USENIX konferentsiyasi materiallari.
  6. ^ Abxishek Arya; Cris Neckar; Chrome xavfsizlik jamoasi. "Xavfsizlik uchun jumboq".
  7. ^ "Firefox-ning xavfsizligi: kodni tahlil qilishning yangi usullarini sinab ko'rish". Arxivlandi asl nusxasi 2016-03-07 da. Olingan 2018-06-18.
  8. ^ "AddressSanitizer tomonidan topilgan ba'zi xatolar".
  9. ^ Mateush Yurchik; Ginvael Koldvind (2014-01-10). "FFmpeg va ming tuzatish".
  10. ^ "FreeType xatolarida AddressSanitizer uchun qidiruv natijalari".
  11. ^ "KernelAddressSanitizer (KASAN)". Arxivlandi asl nusxasi 2016-12-23 kunlari. Olingan 2016-12-08.
  12. ^ Jeyk Edj. "Yadro manzilini tozalash vositasi".
  13. ^ Jonathan Corbet. "3.20 birlashma oynasi 2-qism".
  14. ^ "MemorySanitizer".
  15. ^ "ComparisonOfMemoryTools". Sanitizer Wiki. Olingan 1 dekabr 2017.
  16. ^ "Sanitizer-ni chetlab o'tish" (PDF). Erik Uimberli. Olingan 1 iyul 2014.

Tashqi havolalar